So I have a problem: I usually need to run a folder through an exe, but now I need to run all the folders in a main directory. They don't have any folder depth so one subfolder has no other subfolders. Essentially I drag and drop a folder onto my exe and I get a file from it, I need a batch script that runs all the folders in my directory individually through the exe, as when I run multiple folders through the exe, I still get a single file.
I found this code and this works for all files with the suffix .emb
#echo off
for /r %%i in (*.emb) do "embpack_v2.exe" "%%i" ALL
but I need it to run folders, not files ending in .emb
try with
for /r /d %%i in (*) do "embpack_v2.exe" "%%i" ALL
Related
for /r "C:\Users\bui\Desktop\Annotation Traing Package\test1" %i in (*03.json) do copy "%i" "C:\Users\bui\Desktop\Annotation Traing Package\test2"
i want to copy all 03.json files from test1 to test2 but in test1 folder, there are subfolders, and in those subfolders also have 03.json files. With for loop i cant loop through subfolders and copy 03.json files in it, but i also want to copy those subfolders from test1 to test2 with those 03.jon files in it. is there possible way to do it?
i tried using xcopy to copy those subfolders first then use for loop but no use, bc they copy all files to "C:\Users\bui\Desktop\Annotation Traing Package\test2"
RoBoCopy is the best method to do this IMHO.
Robocopy "C:\Users\bui\Desktop\Annotation Traing Package\test1" "C:\Users\bui\Desktop\Annotation Traing Package\test2" *03.json /E /S /B
The Robocopy utility is made to copy directory trees and matching files and has been included in windows since Windows 7 released in 2009.
Note I used /E assuming you would want the folders which are empty assuming you may have things like log folders which contain no "03.json" files
If you do not want to create empty directories when they do not contain "03.json" files, then simply omit the /E option
I have a batch script which moves all the files from one folder to another and then renames them all to .jpg, however my .bat file itself gets renamed in the process because it sits in the destination folder. I need to exclude it from getting renamed.
Also, does the ren command exclude items in subfolders by default? I only want items in the destination folder renamed, not items in its subfolders.
#echo off
xcopy "C:\Folder1" "C:\Folder2"
cd "C:\Folder2" && ren *.* *.jpg
pause
I believe it should an easy way of doing this, but I could not figure out how.
Current situation:
Customer send zip file to our SFTP folder, by using some easy batch files it copy zip files from SFTP, unzip it and carry on with the rest of the things which has to be done.
What I need:
Inside zip file there is a folder(main problem that it could be named randomly). All what I need is a BATCH file which will copy all files from any existing folders in current(job) location.
Edit:
Current method is a really bad(but it solid and working), I just simply change the name of the folder in batch file and everything run nice and smooth. Method is working fine, but I would like to automate it completely.
You can iterate over the directories in the extracted archive directory using DIR /A:D which only gets directories. This will process more than one subdirectory if it is found.
SETLOCAL ENABLEDELAYEDEXPANSION
SET "EXTRACTED_DIR=C:\path\to\extracted\archive"
FOR /F "usebackq tokens=*" %%d IN (`DIR /A:D /B "%EXTRACTED_DIR%"`) DO (
SET "THE_DIR=%%~d"
ECHO Do something with mystery directory "%EXTRACTED_DIR%\!THE_DIR!"
)
I want to copy all files within subfolders to the parent folder. But want to create a new folder in it by the name "copied" in whichever folder i have copied my batch file. I tried this command.
FOR /R %%# IN (*.*) DO XCOPY "%%#"
It does the job but it keeps asking to rewrite files. Also wasn't sure how to create the folder name in which i have copied my batch file into.
Usually I extract .zip and .rar files in a directory maned as the file without the extension.
E.g.:
test.zip
test\
Now I'd like to write a Windows batch script that browses all hard drive to delete all .zip or .rar files whenever in the same directory is present a subdirectory with same name of the file without the extension.
But I really don't know where to start.
Thank you in advance.
This simple script is all you need to delete all zip files within C: drive appropriately.
#for /r c:\ %%F in (*.zip) do if exist "%%~dpnF\*" del "%%F"
You don't even need the script. You can simply run the following from the command line:
for /r c:\ %F in (*.zip) do if exist "%~dpnF\*" del "%F"