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

x
?
Solved

Dynamic Folder Deletion and contents moved

Posted on 2009-02-12
2
Medium Priority
?
190 Views
Last Modified: 2013-11-05
Greetings-

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].

Assumptions/Situations:
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!

0
Comment
Question by:ckelker
2 Comments
 
LVL 21

Assisted Solution

by:AmazingTech
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

0
 
LVL 1

Accepted Solution

by:
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.
0

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