I am looking to sort approximately 3,000 pdf files into their own folders. All 3,000 files are in one folder and follow the same format.
COURSE NAME - EMPLOYEEFIRSTNAME EMPLOYEELASTNAME
I have made all the folders, but now want to move the appropriate PDF document into the corresponding folder. I found this handy answer to get me started: How to sort files into folders, according to file names - Windows CMD.
This is what I'm currently trying to modify:
:: C:\Users\User\Desktop\Training Test.cmd
@Echo off
PushD "C:\Users\User\Desktop\Training Test"
For %%A in (*.pdf) do For /F "tokens=2,3delims=-." %%B in ("%%A") Do (
If Not exist "%%B" MD "%%B"
Move "%%A" "%%B"
)
PopD
What I'm finding is that it's creating a new folder with a space in front of the employee name. I have a folder named "EMPLOYEEFIRST EMPLOYEELAST
", but its making a new folder of " EMPLOYEEFIRST EMPLOYEELAST
" (note the space at the beginning).
I have also noticed that it creates a new folder for those employees with a hyphenated first or last name. EMPLOYEE-FIRST EMPLOYEE-LAST
just turns into a new folder of " EMPLOYEE
".
I'm very new to all of this. Is there a way of resolving the issues with the space in the folder name and hyphenated names?
No comments:
Post a Comment