|
Answer» Hi,
I need help on this
There is two FILE abcMMDD-123 and abcMMDD-456
in this abcMMDD-123 is 0KB and abcMMDD-456 is 1KB
i want only abcMMDD-456 1KB file to rename (i am using this in a batch file)
ren abcMMDD* filename_to_MMDD.txt Your request isn't very clear.
You've said that you have two files and one of them is zero bytes, and you want to rename the other one.
Explain what you want to rename it to, and also tell us if you are renaming more files at the same time, and if you only want to ignore zero byte files. i just want to skip the 0KB file as i ill be using MMDD - the date which i want to give as %input%
for ex - 0729 today will be having 2 files in which 1 file 0KB and 1 file 1KB, I need this 0kb to skip and 1kb file to rename
See if this helps you.
Code: [Select]@echo off for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a set YYYY=%dt:~0,4% set MM=%dt:~4,2% set DD=%dt:~6,2% set HH=%dt:~8,2% set Min=%dt:~10,2% set Sec=%dt:~12,2%
set d=%MM%%DD%
for /f "delims=" %%a in ('dir "*%d%*" /b /a-d ') do ( if %%~za GTR 0 ren "%%a" "something else" ) pausebut both the file generates at the same time, no diffrence in timing
The code doesn't check by time, it checks the filesize which is what you asked for.
If it doesn't do what you want to do then please clarify the task and provide further details.
@ ECHO OFF ECHO TYPE THE DATE AND PRESS ENTER, PRESS F6 AND PRESS ENTER AGAIN. ECHO. ECHO Enter date below in MMDDYYYY format now: FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A
ECHO TYPE THE TIME AND PRESS ENTER, PRESS F6 AND PRESS ENTER AGAIN. ECHO. ECHO Enter time below in HHMMSS format now: FOR /F "tokens=*" %%B IN ('TYPE CON') DO SET INPUT1=%%B
d: ren abc* rename_to_%input%_%input1%.txt
pause
output for this will be rename_to_MMDDYYYY_HHMMSS.txt
in this 0 kb file needs to remain same with out renaming
the below example files are SYSTEM generated file the NUMBERS what mentioned will change on daily basis.
abcMMDD-123 is 0KB and abcMMDD-456 is 1KB
I am beginner...
any update... please give me the batch script which will work on thisI don't think this will correct your problem, but you can replace 'for /f "tokens=*" %%A in ('type con') do set input=%%A' with 'set /p input="
It should save you some time typing.This is what you seem to want, judging from your code.
Code: [Select]@echo off for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a set YYYY=%dt:~0,4% set MM=%dt:~4,2% set DD=%dt:~6,2% set HH=%dt:~8,2% set Min=%dt:~10,2% set Sec=%dt:~12,2%
for /f "delims=" %%a in ('dir "abc*" /b /a-d ') do ( if %%~za GTR 0 ren "%%a" "rename_to_%YYYY%%MM%%DD%_%HH%%Min%%sec%.txt" ) pauseHi
this is not working
what is the meaning of GTR in the qury ?QUOTE from: itkesavan on July 30, 2013, 08:21:36 PM Hi
this is not working
What error message do you get?
Quote from: what is the meaning of GTR in the qury ?
It means greater than
|