Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all,

I have a folder which has logs of past 1 year in it day wise. I want to copy this log in a new folders month wise. for example my january file should have all the logs of jan.
like that i want it to do for every month . can any body help me on this. Thanks in advance.
Posted
Comments
Peter Leow 5-Jan-15 2:32am    
Show sample of log data.
syedmas 5-Jan-15 2:40am    
its just a text files which gets generated day wise every day. like autologqwj.txt
i want to keep this files in a folder month wise
syedmas 5-Jan-15 2:42am    
there is one folder which has 365 files which was generated everyday. now i want to move or copy this file into a folders month wise from jan to dec.
syedmas 5-Jan-15 4:09am    
sir can you help on this.
Tomas Takac 5-Jan-15 4:28am    
What have you tried? Where are you stuck? What about xcopy with /D parameter?

1 solution

@echo off

:: Looping through the list for different folders

for /f %%a in (folderlist.txt) do (
echo %%a

@echo off
set "src=D:\folder\copyingfrom\%%a\Processing"
set "dest=D:\folder\copiedto\%%a\Processing\MonthWise"
for %%F in ("%src%\*") do (
for /f "tokens=1,2,3 delims=/ " %%A in ("%%~tF") do (
if not exist "%dest%\%%C_%%A" mkdir "%dest%\%%C_%%A"
::move "%%~fF" "%dest%\%%C_%%A"
xcopy /Y "%%~fF" "%dest%\%%C_%%A"
)
)
)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900