Hey all, new to this place. Hoping you can help me with a work task. We are re-organizing the way our files are organized and have several thousand items that need work. This is something I'd like to automate.
I have (3) primary goals:
1. Create a folder name based on the file name. File name can vary in length, but typically in this format: 12345 - Project Name - City, ST.xls
2. Once the new folder name is created, create (4) subfolders called: Quote, Submittals, Cut Sheets & Correspondence.
3. Move original file (12345 - Project Name - City, ST.xls) and place inside the Quote folder.
No idea where to start. Please help. Thanks.
Create Folder Based on Filename + Subfolders + Move Files
Moderator: DosItHelp
-
- Posts: 2
- Joined: 27 May 2014 14:16
Re: Create Folder Based on Filename + Subfolders + Move File
Could you clarify bullet point 1 please? Based on the filename what do you want the base folder name to be?
-
- Posts: 2
- Joined: 27 May 2014 14:16
Re: Create Folder Based on Filename + Subfolders + Move File
Squashman wrote:Could you clarify bullet point 1 please? Based on the filename what do you want the base folder name to be?
Absolutely.
Folder name needs to duplicate entire file name sans the file extension. So in the example, the file name is 12345 - Project Name - City, ST.xls and I would need the folder name to be 12345 - Project Name - City, ST.
Re: Create Folder Based on Filename + Subfolders + Move File
Test this in a copy of your folder tree.
Code: Select all
@echo off
for /f "delims=" %%a in ('dir /b /s /a-d *.xls ') do (
md "%%~dpna" 2>nul
md "%%~dpna\Quote" 2>nul
md "%%~dpna\Submittals" 2>nul
md "%%~dpna\Cut Sheets" 2>nul
md "%%~dpna\Correspondence" 2>nul
move "%%a" "%%~dpna\Quote" >nul
echo processed "%%a"
)
echo done
pause