Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATE NEW FOLDER BATCH FILE 1

Status
Not open for further replies.

dilworth

Technical User
May 29, 2002
59
GB
Is it possible to write a Batch File that will automate creating New Sub Folders-New Folders need to be created each day in several Directories in the following Format:-

01.02.05
02.02.05
03.02.05
04.02.05
05.02.05

Any Suggestions Much Appreciated
 
well... create a .bat file and open it in notepad

the dos command to create a directory is mkdir

so it would look something like this...




Echo. Test Batch File To Create Directories

REM Place Pathname to folder where new folders will be placed here:
c:\test\testbatchfile\

mkdir 01.02.05
mkdir 02.02.05
mkdir 03.02.05
mkdir 04.02.05
mkdir 05.02.05
mkdir 06.02.05

Echo. Test Batch File Completed. Thank You


Save the file, then run it in the directory where you want the new folders.

You could make it even more interactive then that...

Computer/Network Technician
CCNA
 
; good until year 2010

for /f "tokens=2 delims= " %%a in ('date /t') do set dtemp=%%a

for /f "tokens=1-3 delims=/" %%a in ("%dtemp%") do (set month=%%a& set day=%%b& set year=%%c)

for /f "tokens=2 delims=0" %%a in ("%year%") do set year=%%a

md %day%.%month%.0%year%

; end


Notes:
. a script would have been easier than a batch file
. You can either CALL this from a batch file that CD's into all the subfolders; or use this once in a template folder and then use XCOPY /T /E to repeatedly call this to duplicate the directory structure of the template folder to other folders




 
Thank you for this-I have copied the commands into command editor and the following error message is displayed:

%%a was unexpected at this time.

Please can you advise a solution to this.
 
Try a copy/paste from the text above.
There is a critical blank space in the first line:
Code:
for /f "tokens=2 delims= " 
                        ^

 
Also, make sure you open notepad and paste the above into a file, to be called some_filename.bat
You cannot run each line outside of a .bat file to have it make sense.

 
Thanks,
Is it possible to use the same variables that create a folder based on the Current Date to rename folders to 'Filename_Current Date'-tried using the same commands with the rename command but this has not worked.
 
; good until year 2010

for /f "tokens=2 delims= " %%a in ('date /t') do set dtemp=%%a

for /f "tokens=1-3 delims=/" %%a in ("%dtemp%") do (set month=%%a& set day=%%b& set year=%%c)

for /f "tokens=2 delims=0" %%a in ("%year%") do set year=%%a

ren *.* *_%day%.%month%.0%year%.*

; end

 
I have tried this command to rename a file but it is not working correctly e.g

tried to rename a file called ab.txt to ab15032005.txt and when the file is run the file is renamed to ab....txt-any suggestions as to what could be the problem is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top