Delete a subdirectory and move the files to the parent

Bulk Rename Utility How-To's

Delete a subdirectory and move the files to the parent

Postby SGirard » Mon Nov 09, 2020 11:03 pm

Hi everyone,

I didn't see this question in the list so i hope that i didn't just missed it.

I have an export utility that will automatically create folder that would look like this
c:\Export\Client1\Correspondance\General\Filename1.msg
c:\Export\Client1\Correspondance\Unclassified\Filename2.msg
C:\Export\Client2\Tax\return\taxreturn1.pdf
c:\Export\Client2\tax\unclassified\Working paper.xls

I would like to scan the whole Export folder and take all files in the different \Unclassified\ folders and bring it to the parent folder and get rid of the folder.
So the result would look like:
c:\Export\Client1\Correspondance\General\Filename1.msg
c:\Export\Client1\Correspondance\Filename2.msg
C:\Export\Client2\Tax\return\taxreturn1.pdf
c:\Export\Client2\tax\Working paper.xls

Is there anyway to do this?

Thanks for your help!
SGirard
 
Posts: 1
Joined: Mon Nov 09, 2020 10:54 pm

Re: Delete a subdirectory and move the files to the parent

Postby Luuk » Wed Nov 11, 2020 10:59 pm

Greetings SGirard. Im thinking this requires the experts for javascript code in Special(14), but after searching the forums, nowhere did I find some code like this.
If the experts not can help, I can post batch with exiftool that conducts like your explanation.
Luuk
 
Posts: 705
Joined: Fri Feb 21, 2020 10:58 pm

Re: Delete a subdirectory and move the files to the parent

Postby Admin » Thu Nov 12, 2020 12:22 am

Hi, this sounds like something you would do with a Powershell script.
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: Delete a subdirectory and move the files to the parent

Postby Luuk » Thu Nov 12, 2020 1:26 am

Yes, Im now thinking to just use a simple batch!
Code: Select all
@echo off
cd C:\Export
for /f "delims=" %%A in ('dir /b /s unclassified') do (
move "%%A\*" "%%~dpA"
rd "%%A"
)
echo Done, press any key to continue
pause>nul
Luuk
 
Posts: 705
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To