Batch Move files
Moderator: DosItHelp
Batch Move files
Hi there , Im new to your forum and am glad to meet you all !
So I have a problem with a huge amount of files I need to move up one level to its parent directory.
I have searched all around but it seems like my issue is unique ( perhaps )
Bascally I have 3 levels of sub folders and I need to eliminate the third .
The third level has multiple folders and each individual folder has a .pdf inside.
So the four subfolders in the picture need to go leaving the pdfs inside the "attendance" folder like this
So what ive been doing is searching with * in the second level, cutting the pdfs out of the third, returning to the second and pasting then deleting the empty third level folders after.
This isnt so bad for one folder but Ive got 1080 folders to go though
Im not familiar with making my own script but ive seen them in action and they seem super powerful when done right.
Is what im asking doable with one script or do i have to make one for each of the third level sub folders since they all have unique names.
I with I could just select them all and click move to parent directory but thats in a perfect word huh.
Any help is greatly appreciated !
Thanks ,
Dan.
So I have a problem with a huge amount of files I need to move up one level to its parent directory.
I have searched all around but it seems like my issue is unique ( perhaps )
Bascally I have 3 levels of sub folders and I need to eliminate the third .
The third level has multiple folders and each individual folder has a .pdf inside.
So the four subfolders in the picture need to go leaving the pdfs inside the "attendance" folder like this
So what ive been doing is searching with * in the second level, cutting the pdfs out of the third, returning to the second and pasting then deleting the empty third level folders after.
This isnt so bad for one folder but Ive got 1080 folders to go though
Im not familiar with making my own script but ive seen them in action and they seem super powerful when done right.
Is what im asking doable with one script or do i have to make one for each of the third level sub folders since they all have unique names.
I with I could just select them all and click move to parent directory but thats in a perfect word huh.
Any help is greatly appreciated !
Thanks ,
Dan.
Re: Batch Move files
Try the following script
Of course you have to customize variable "folder". NOTE that all of the pdf files have to have unique file names. Batch does not automatically add something like (2) to the file name but simply overwrites a file that has the same name.
Steffen
Code: Select all
@echo off &setlocal
set "folder=C:\wherever\AGTRARAP^ SUGAR MAY^ 777407\Attendance"
for /f "delims=" %%i in ('dir /a-d /b /s "%folder%\*.pdf"') do move "%%~i" "%folder%\"
for /d %%i in ("%folder%\*") do rd /s /q "%%i"
Of course you have to customize variable "folder". NOTE that all of the pdf files have to have unique file names. Batch does not automatically add something like (2) to the file name but simply overwrites a file that has the same name.
Steffen
Re: Batch Move files
Hi aGerman, Thanks for your reply.
The "folder" varialble represents the root , like the first level l? Here is an example of another file placement
G:\JOB FOLDER\FOLDER1\FOLDER2\EMPLOYEE NAME\SECOND LEVEL\THIRD LEVEL followed by the .PDF
The files names are no problem, ive bulk renamed them with numbering as a suffix.
Here is a clearer view of the file structure.
(sorry for the sideways image.. it uploaded that way..)
So as I said I need to eliminate the 3rd level (orange highlight) so that the pdfs fall in to the second level ( yellow highlight )
Will I have to create a unique script for each of the second level sub folders?
Thanks again for your help,
I really appreciate it !!
Dan.
The "folder" varialble represents the root , like the first level l? Here is an example of another file placement
G:\JOB FOLDER\FOLDER1\FOLDER2\EMPLOYEE NAME\SECOND LEVEL\THIRD LEVEL followed by the .PDF
The files names are no problem, ive bulk renamed them with numbering as a suffix.
Here is a clearer view of the file structure.
(sorry for the sideways image.. it uploaded that way..)
So as I said I need to eliminate the 3rd level (orange highlight) so that the pdfs fall in to the second level ( yellow highlight )
Will I have to create a unique script for each of the second level sub folders?
Thanks again for your help,
I really appreciate it !!
Dan.
Re: Batch Move files
The "folder" varialble represents the root
That's how I understood it. Just copy a small section of your original data in order to do some tests.
Steffen
Re: Batch Move files
So im really not sure what im doing..
I created a test file structure.
https://drive.google.com/open?id=0B6L96 ... 3FRVHJEUXc
If you have the time, could you show me what i need to do to obtain my goal?
Thanks a million !
I created a test file structure.
https://drive.google.com/open?id=0B6L96 ... 3FRVHJEUXc
If you have the time, could you show me what i need to do to obtain my goal?
Thanks a million !
Re: Batch Move files
From where do you want the script to begin searching for the pdf files? From "root" or from "lvl1"?
Steffen
Steffen
Re: Batch Move files
Hi , been a bit busy sorry for my late response.
The pdfs from the 3rd level (lvl3 - XX) are the ones I need to move, Im guessing it would need to search there ?
Thanks again for your help !
The pdfs from the 3rd level (lvl3 - XX) are the ones I need to move, Im guessing it would need to search there ?
Thanks again for your help !
Re: Batch Move files
That's what I already understood. My question was where the script should start from. In the ZIP example you currently have one subfolder ("lvl1") in "root". Imagine you would have more subfolders (e.g. "foo" and "bar") in "root" and you would let the script start searching from "root" then all pdf files you may have in "foo" and "bar" would have been processed, too.
Again - Do you have several level 1 folders in root that you want to process in the way you described? Or should the script start in the one and only level 1 folder that you have in your example?
Steffen
Again - Do you have several level 1 folders in root that you want to process in the way you described? Or should the script start in the one and only level 1 folder that you have in your example?
Steffen
Re: Batch Move files
Ohh I think I see what you mean
So yes, In my real files there are several lvl1 subfolders in the root dir. So if i understand correctly, the script needs to search from root and not lvl one.
So yes, In my real files there are several lvl1 subfolders in the root dir. So if i understand correctly, the script needs to search from root and not lvl one.
Re: Batch Move files
Save this code in root.
Steffen
Code: Select all
@echo off &setlocal
for /d %%i in (*) do for /d %%j in ("%%i\*") do for /d %%k in ("%%j\*") do (
for %%l in ("%%k\*.pdf") do move "%%l" "%%j\"
rd /s /q "%%k"
)
Steffen
Re: Batch Move files
Append a PAUSE as last line and see if you get any error messages.
Make sure you saved it ANSI encoded. Or use the script in the attached ZIP.
Steffen
Make sure you saved it ANSI encoded. Or use the script in the attached ZIP.
Steffen
- Attachments
-
- testmove.zip
- (235 Bytes) Downloaded 314 times
Re: Batch Move files
YES ! I downloaded the file you attached and it worked like a charm !
You just saved me SOOOOO much time !!!! WOW !!!!
Thanks sooooo much!!!!
I Owe you big time !!!
You just saved me SOOOOO much time !!!! WOW !!!!
Thanks sooooo much!!!!
I Owe you big time !!!
Re: Batch Move files
Not worth talking about You're welcome!