| 1. |
Solve : Create folder from first 5 chars of filename (and move the file to it.)? |
|
Answer» Here's what I have. Except the capital A in line 4 had to be lowercase. Yes, I made a typo. I am so used to using capital letters for the FOR variables. There is a reason - SEE if you can spot it in the FOR help. I looked hard but I couldn't see the word "thanks" anywhere in your post... This has been tested and works with the corrected A to a case-change. Thank you for the support on this, I'm learning so much about For loops from these tasks! Brilliant stuff guys Thanks a lot. I adaped your script to pickout the date from the file name of a PDF report, then move that report to a folder with that date ( for archiving): Example file name: R9621_XJDE001_D1111201_T161418976.pdf ECHO OFF setlocal enabledelayedexpansion for /f %%a IN ('dir /b T:\B7333\PrintQueue\*.pdf') do ( set filename=%%a set last21=!filename:~-21! Set pdfdate=!last21:~0,6! mv %%a pdfdate/ ) Quote from: billiehawkins on October 25, 2011, 01:09:33 PM This worked,Shouldn't that set statement be: Code: [Select]set first5=!filename:~0,5! |
|