| 1. |
Solve : move each file to a separate folder? |
|
Answer» hi The process cannot access the file because it is being used by another process. i even restart my system but nothing has changed i can identify and move all of these files with other batch files so what's wrong? Quote from: mioo_sara on May 30, 2009, 05:27:05 AM thanks dear devcom for your fast replyFirst off, files that are being used by another process or computer can't be modified or moved until whatever else is using them has stopped. Code: [Select]echo off setlocal enabledelayedexpansion for /f "tokens=*" %%A in ('dir /b *.exe') do ( set fileName=%%~nA md "!fileName!" taskkill /F /IM "%%A" echo move "%%A" "!fileName!\setup.exe" ) pause try now if this will work REMOVE echo from 8 line Quote First off, files that are being used by another process or computer can't be modified or moved until whatever else is using them has stopped. so why i can move them with below SCRIPT? Quote echo off & setLocal EnableDelayedExpansionwow !! it worked devcom thanks my man although i saw error message for all files but this time all the folders have created and they are all renamed and exe files are moved and renamed wonderful now dear devcom if its ok with you can you help me with this 2 last request? question 1= there are some more files (.com and .txt) files in this folder next to the others (exe file) now i wnat them to be moved to one folder (each one) so how can we change above script? i changed Quote for /f "tokens=*" %%A in ('dir /b *.exe') do ( so is there any problem with that? so what about this line? echo move "%%A" "!fileName!\setup.exe" this command rename all file to setup.exe so what can i do for .txt and .com files? txt file should be rename to readme.txt .com files should be rename to setup.com question 2= some of files have "update" or "uninstall" word in their names these kind of files should be renamed to update or uninstall (ignore to rename them to setup) thanks my dear devcombut you want to do this the same way as .exe for .txt and c.om ? so you have file test1234.txt and you want to make test1234 folder and put the .txt file there as readme.txt ?sorry dear devcom for answering late yes i want the exact of operation that you mentioned thanks i am waiting Code: [Select]echo off setlocal enabledelayedexpansion for /f "tokens=*" %%A in ('dir /b *.exe *.txt *.com') do ( md "!fileName!" 2>nul set fileName=%%~nA ::set fileName=!fileName:update=! ::set fileName=!fileName:uninstall=! set fileExt=%%~xA if "!fileExt!" equ ".txt" (set moveName=readme) ELSE (set moveName=setup) call :FIND "%%A" echo move "%%A" "!fileName!\!moveName!!fileExt! ) pause exit :FIND set find=%~1 echo.%find% |findstr /I "uninstall" >nul && set moveName=Uninstall echo.%find% |findstr /I "update" >nul && set moveName=Update exit /b this should work PS you can remove :: from 8,9 line to make folders without update or uninstall word ,i mean if you have file: 'test update.exe' it will create 'test' folder instead of 'test update' folder if you delate :: PS.2 ofc you need to remove echo if this will workWhy does "Mioo_Sara" want to move ".exe" files into separate unique folder? What is the goal of such a strange movement of .exe files? What is Mioo_sara trying to accomplish? Quote from: mioo_sara on May 30, 2009, 03:45:59 AM himaybe he created 1000 apps and now he want to clean his computer ? Quote from: devcom on May 30, 2009, 03:51:10 PM maybe he created 1000 apps and now he want to clean his computer ? If clean the computer of .exe files, then del is better than move. The movement of .exe to a unique folder was not restricted to .exe files created by the user. It is and was a nonsense and dangerous exercise to move .exe files to a unique folder.billrich is right, this is odd. |
|