Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi
C:\Documents and Settings\user\Desktop\clients\x\t
is the folder tree i am working on.
the batch file is placed on the desktop.
i have the following code to delete all *.jpeg files from the folder "t"@echo off
dir /s/b/ad "C:\Documents and Settings\user\Desktop\clients"
find /v /i "C:\Documents and Settings\Documents and Settings\user\Desktop\clients"for %f in (*.*) do @del /s %%f
::done
pause
if u look above after clients as per the structure it would show a folder "x" and then the folder "t" . both these folders are displayed on the screen when i run the above batch file.BUT it does not delete the *.jpeg inside the "t" folder. also i dont want to delete any *.jpeg in any other folder ie client,x.
kindly help .
is there some problem with my for command?very urgent.please help
cheers!!!

@echo off
cd..
dir /s/b/ad "C:\Documents and Settings\user\Desktop\clients"
find "*.xml" "C:\Documents and Settings\Documents and Settings\user\Desktop\clients" <tif exist *.jpeg echo y | del /s *.jpeg
:: DONE
pause
i modified the code to above..but when i run it it gives the error:
cannot find the file !!
why is is not able to find the jpeg's?
kindly help

@echo off
dir /s /b "C:\Documents and Settings\user\Desktop\clients\x\*.jpeg" > Files.txt
for /f %%a in (Files.txt) do del %%a

Call me simple minded.
del /s "C:\Documents and Settings\user\Desktop\clients\x\t\*.jpeg"
If at first you don't succeed, you're about average.M2

@dtech and mechanix2go
@echo off
dir /s /b "C:\Documents and Settings\user\Desktop\clients\x\*.jpeg" > Files.txt
for /f %%a in (Files.txt) do del %%athis is a simple solution BUT THE x folder changes everytime ..ie the name of this folder changes .
hence i wrote the above code, my second post so that the program automatically tracks the contstant "t" folder and deletes the *.jpeg files of it.
i repeat all the jpeg files of t folder should only be deleted.
the name of "x" folder varies and only the path uptil clients remains the same. ofcourse the "t" folder also remains the same.
kindly help now
cheers

@echo off
dir/s/b/ad "c:\Documents and Settings\user\Desktop\clients\" |find /i "\t" > #
for /f "tokens=*" %%D in (#) do echo del "%%D\*.jpeg"===
That's 3 lines beginning with:@echo
dir
for
If at first you don't succeed, you're about average.M2

@Mechanix2go
sorry friend that doesnt work.
the .jpeg files in "t" are not deleted. the dos screen flashes when i run the file, but nothing happens.
kindly help
cheers

the error message is:
the system did not find the file specified.
although i have checked all the folders and files are intact.
kindly help

@echo off
setlocalset FolderPathBase=C:\Documents and Settings\user\Desktop\clients\*.*
for /f "tokens=*" %%i in ('dir /b /ad "%FolderPathBase%"') do (cd /d "%FolderPathBase%\%%i\" && del . /s /q >nul 2>&1)
endlocal
ok now the above code is working for deleting the fileS BUT it is also deleting the .jpegs inside "x" whereas only those inside "transmittal" should be deleted.
kindly help
very near..yet so far
cheers

If you look at this lline:
for /f "tokens=*" %%D in (#) do echo del "%%D\*.jpeg"
from #5 you may notice that because of the "echo" it doesn't *DO* any deletion, but simply verifies that it's on tyhe right track. I did this to keep from creating a loose cannon.
Edit out the "echo" from that line and I think it will work.
BTW doing a global delete after a CD is a BAD idea. If the CD fails, you've got trouble.
If at first you don't succeed, you're about average.M2

@echo offsetlocal
set FolderPathBase=C:\Documents and Settings\user\Desktop\c\*.*
for /f "tokens=*" %%i in ('dir /b /ad "%FolderPathBase%"') do (cd /d "%FolderPathBase%\%%i\transmittals\ " && copy C:\Documents and Settings\user\Desktop\c\x\t\2.xml C:\y >nul 2>&1)
endlocal
pause
why doesnt the copy command work?
if i replace copy by del *.jpeg /s it works fine and does what is desired. but NOW I WANT TO JUST MOVE THE FILE FROM THE FOLDER TO ANOTHER FOLDER. BUT IT GIVES ERROR--path not found.why??
kindly helpcheers

Hi
Hi
Maybe I'm on the wrong track here, but will this work.
delete the /p which asks for confirmation.
delete it if works ok.
@echo off
dir /b /s /ad| find /i "Documents and Settings\user\Desktop\clients\" | find /i "\x\t" >Dirs.txt
for /f "tokens=*" %%a in (Dirs.txt) do if exist "%%a"\*.jpeg del "%%a"\*.jpeg /p

i said i want to MOVE the file to a diff folder using the move comamnd. but it aint works. del is working fine as in my earlier posts.
kindly help cheers

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |