[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Dynamic Folder Deletion and contents moved

Posted on 2009-02-12
Medium Priority
Last Modified: 2013-11-05

I have a script which is simple, but it needs to have a bit of coding to determine what actions to complete.  Here's the scenario:

Current usage
>>abc.bat  E:\MyFiles TheNewFolder
runSomething.exe %1\%2  //this application foolishly creates a NEW subfolder
//Now exists ---  E:\MyFiles\TheNewFolder\NewSubFolder1828\

The new code needs to copy the files and folders from new *name unknown* subdirectory (named NewSubFolder1828 above) up one level to the [TheNewFolder].

There is only one sub folder.
There are files in the [TheNewFolder] along with the single sub folder.
All the files and folders in the sub folder need to be moved (up one level).
RunSomething.exe basically creates a timestamp folder that is messing everything up!

Question by:ckelker
LVL 21

Assisted Solution

AmazingTech earned 200 total points
ID: 23629866
Try this.
runSomething.exe %1\%2
for /f "tokens=*" %%a in ('dir /ad /b "%1\%2"') do XCOPY /y /s /c /h "%1\%2\%%a\*.*" "%1\%2\*.*"

Open in new window


Accepted Solution

ckelker earned 0 total points
ID: 23747116
Sorry for the delay...

Code above didn't seem to work but thankfully the required application was tweaked.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question