Batch Moving Files in Folder of FileDate-Part

January 4, 2011 at 02:53:32
Specs: Windows XP
Hi all,

I have a lot of Files in an Folder. These Files should be moved in an new Folder with the Month and Year of the File.

For example:

23.09.2009 Tesla - 2010 - Alive in
07.05.2009 Tesla - 1991 - Psychotic

==> Create a Folder 2009-09 and move all file with this Date xx.09.2009 in it
==> Create a Folder 2009-05 and move all file with this Date xx.05x2009 in it
==> Create a Folder 2009-05 and move all file with this Date xx.11x2009 in it

and so on ...


See More: Batch Moving Files in Folder of FileDate-Part

Report •

January 10, 2011 at 14:49:06

Try this ...It shoud work.


Set MM=%date:~4,2%
Set DD=%date:~7,2%
Set YYYY=%date:~-4%
cd d:\temp
dir /b *.info | findstr /v "bat" | findstr /v "filelist.txt" >filelist.txt

for /f "tokens=1,2,3,* delims=. " %%a in (filelist.txt) do (
set dirname=%%c-%%b
md !dirname!
move "%%a.%%b.%%c %%d" !dirname!\



put the batch file in same folder and run it..

Subhash Chandra.

Report •

January 11, 2011 at 10:27:12
Thanks for the Post!

... it was my fault , that i write my Post so bad ... sorry.

Yes it work's if i want to use it in your way .... but ...
The Date isn't in the Filename , it means ... i want to read out the file creation date and use this Date to create the folder, also i want to use this date to move the file in the folder ... (mabye with FOR ... %%~ta% ...) ???

Thanks ...

Report •

January 11, 2011 at 10:58:55
How to exstract the info you want...

for /f "tokens=*" %%a in ('dir c:\ /s /b') do (
set T=%%~Ta
set Month=!T:~0,2!
set Day=!T:~3,2!
set Year=!T:~6,4!
echo File: %%a Year: %Year% Month: %Month% Day: %Day%

I give you the tool the rest is up to you.

Report •

Related Solutions

January 11, 2011 at 13:40:28
OK !! ... GREAT !!! .... good Job !

Thank you all for support ... now it works how i like it ...

@rem ===== BATCH SCRIPT BEGIN =====
@echo off

setLocal EnableDelayedExpansion

set workdir=d:\DOWNLOADS\_INFO

for /f "tokens=*" %%a in ('dir /b %workdir%\*.info') do (
set T=%%~Ta
set Day=!T:~0,2!
set Month=!T:~3,2!
set Year=!T:~6,4!
set folderName=!Year!_!Month!
if not exist "%workdir%\!folderName!" md "%workdir%\!folderName!"
set filename=%%~NXa
move "%workdir%\!filename!" "%workdir%\!folderName!\!filename!"

setLocal DisableDelayedExpansion

echo Done !!!
echo =============================================

@rem ===== BATCH SCRIPT END =====


Report •

May 10, 2011 at 07:00:21
Hello all, I have a similar issue that I really need some help with. I have a huge folder filled with PDF files. So huge that it takes me hours to run a "dir" command on it. These files have been accumilating over the span of 5 or 6 years. I would like to see a script that would sort the files based on the year in which they were created, create a folder and name it the year and move the file(s) to it. In other words if I have 2000 files that were created in the year 2007, create a folder called 2007 and move all the files created in 2007, to it.

Report •

Ask Question