| 1. |
Solve : Delete files taht are not AVI? |
|
Answer» A paid service downloads video files in AVI format. Along with the videos come other files that are no longer needed after the download is finished.
Add the /i switch or it will delete .AVI files or .aVi files etc. The CASE insensitive switch will fix that. Code: [Select]for %%A in (*.*) do if /i not "%%~xA"==".avi" del "%%A"Quote from: foxidrive on May 25, 2013, 10:47:23 PM Add the /i switch or it will delete .AVI files or .aVi files etc. The case insensitive switch will fix that.Cool ! Didn't know.Quote from: foxidrive on May 25, 2013, 10:47:23 PM Add the /i switch or it will delete .AVI files or .aVi I can't imagine that mattering. Not mattering if it deletes your collection of AVI files? Quote from: foxidrive on May 26, 2013, 02:22:03 AM Not mattering if it deletes your collection of AVI files? Of course... I posted UNTHINKINGLY... a very good point. You can force lower case with a rename of the extension. But then it would not be a one-liner. rename *.AVI *.avi Quote from: Geek-9pm on May 26, 2013, 09:48:47 AM You can force lower case with a rename of the extension. As the REN command ignores case, we can protect the avi files with a temporary dummy extension, and then rename back, forcing every .avi extension to a chosen case. In this example it is lower case. It will all go in one line. in a batch... ren *.avi *.avi$$$ & for /f "delims=" %%A in ('dir /b *.* ^| find /v "%~nx0"') do if not "%%~xA"==".avi$$$" del "%%A" & if exist *.avi$$$ ren *.avi$$$ *.avi before aaaaa.bat test0.AVI test1.Avi test2.aVI test3.aVI test4.aVi test5.aVI test6.avi test7.txt test8.doc test9.zip testA.aaa testB.bbb testC.ccc after aaaaa.bat test0.avi test1.avi test2.avi test3.avi test4.avi test5.avi test6.aviUpdate (ignores directories in the folder) Note: batch does not delete itself Code: [Select]ren *.avi *.avi$$$ & for /f "delims=" %%A in ('dir /b /a-d ^| find /v "%~nx0"') do if not "%%~xA"==".avi$$$" del "%%A" & if exist *.avi$$$ ren *.avi$$$ *.aviYour original suggestion with case insensitive switch will work fine, except it will delete the bat file. This should cater for that. Code: [Select]for %%A in (*.*) do if /i not "%%~nxA"==%~nx0" if /i not "%%~xA"==".avi" del "%%A" |
|