How to add a file in multiple zip files? - windows

Im trying to move a picture in every zip folder in current directory. I searched online for some guidance on how to do it using batch (.bat) and the only solution I figured out is to make a macro of it but it takes too long for it to complete.
Edit:
I have 50 zip folders which I want to add a picture inside each one in a faster way other than draging the picture each time inside each of the 50 zip folders.
I would appreciate any other ideas and help you could offer.

Test this on some sample zip files in a test folder. It assumes 7-zip is in the folder shown.
It's not so much faster as it is easier, without manually manipulating the files.
The actual zipping speed will be pretty much the same.
#echo off
for /f "delims=" %%a in ('dir *.zip /b /a-d') do (
"C:\Program Files\7-Zip\7z.exe" a "%%a" "my-picture.jpg"
)
pause

Adds (or updates) README.txt in the zipfiles foo.zip and bar.zip from README.txt in the current directory:
$ for f in foo.zip bar.zip ; do zip -u $f README.txt ; done

You can package files into a zip file using the Winzip utility. It must be installed on your computer. Follow these steps:
Select the files you need and click on any of the selected ones.
Select Add to Zip
In the Add window, in the Add to Archive field, specify the path and name of the archive to be created.
The ZIP file is saved at the path you specified.

Related

How to batch copy a list of folders and its file contents from a text file into a new folder in windows

I have a folder with approximately 7000 subfolders. I am interested in copying 1500 of those subfolders and their file contents into a new folder.
The closest I have got is copying the subfolders file contents into a new Target folder. However, the file contents are not copied over within their resepective subfolder making the batch copy useless to me.
Here is what I have tried.
CD E:\Source_Folder
FOR /F "delims=" %%N in (List.txt) do COPY "%%N" "Target_Folder"
I have tried XCOPY, ROBOCOPY, as well and all give me the same output of individual files in my target folder. I am looking for the subfolders with their contents to be copied into my new target folder.
Any help would be much appreciated. Thanks!
Just a try: rsync in linux does have the option to take the file-list to be synced from a file. Maybe robocopy (which is the windows-pendant) has the same capability, then you need one robocopy x y z only.
-edit: robocopy can'r read from a file, but if you search for 'robocopy reading from list' you get a lot of short scripts.

Batch OCR files in subfolders and save new files with new name

I have the following code, which OCR's all PDF files in a specific folder (d:\extracttmp2), but it does not rename the files as I would like, or put the new files in the right place.
Currently, all files are within subfolders of 'extracttmp2'.
The OCR runs correctly, but I would like the OCR'ed files to be renamed to: <parent folder path>-<filename>_ocred.pdf. Naming them in such a manner will produce no file overwrites.
Currently, the code OCR's the files, but it saves the new files to the folder above the folder they are located in. It also saves the filenames as "JAN_ocred.pdf", for example, for a file named "JAN.pdf". The result of saving up one folder leads to some file overwrites, which is unwanted.
Also, it doesn't matter if the OCR'ed files remain in the folder where the un-OCR'ed files are located, or if they're saved up one folder. The desired renaming will eliminate any overwrites.
The software I'm using is PDF24. https://creator.pdf24.org/manual/10/#command-line. However, I think that my problem is not with the OCR software, but my syntax in the batch script.
Can anyone tell me what I am doing wrong?
For /R d:\extracttmp2\ %%G in (*.pdf) do "C:\Program Files\PDF24\pdf24-Ocr.exe" -outputFile "%%~nG_ocred.pdf" -language eng -dpi 300 -skipFilesWithText "%%G"
Is this what you mean? i.e. files will be saved in the same location as before, but each name will be prefixed with their parent directories' name, followed by a hyphen/dash.
#For /R "D:\extracttmp2" %%G In (*.pdf) Do #For %%H In ("%%~dpG.") Do #"%ProgramFiles%\PDF24\pdf24-Ocr.exe" -outputFile "%%~nxH-%%~nG_ocred%%~xG" -language eng -dpi 300 -skipFilesWithText "%%G"
Just a quick clarification: D:\extracttmp2\directory1\JAN.pdf would be saved in the working directory with the name directory1-JAN_ocred.pdf, and D:\extracttmp2\directory2\subdirectory3\SOMENAME.pdf, as subdirectory3-SOMENAME_ocred.pdf
If you want to save the files somewhere else, either change the working directory, or prepend it to %%~nxH-%%~nG_ocred%%~xG

run texconv windows batch file, recursively and output to the same folder as source?

im running texconv-r.bat in this directory:
I've included "/r" so that it runs recursively on folder "sub" too
for /r %%f in (*.jpg, *.png, *.bmp) do ( texconv -pow2 -f BC1_UNORM %%f )
however, the output places the contents of the sub directory, in the batch file directory:
rather, I would like it outputted to the same directory - the sub directory
I cant figure out what i need to change in the batch file to make this work? ive tried what's recommended in this post but i cant get it to work
Thanks in advance

Directing files in different folders through couple programs with .bat

Basically, I'm trying to batch-compress .png images which are residing in various folders. For that, I use pngquant and pngout. Every image should go through these apps this way:
pngquant.exe --force --speed 1 --verbose image.png -o step1.png
pngout.exe step1.png step2.png
I want all images compressed at once. To gather a list of all images in folders, I search with *.png query in root folder. The aim is to just throw all images to batch file and wait for the result.
I looked around a bit and come up with this
for %%i in (*.png) do (
"...\pngquant.exe" --force --speed 1 --verbose "%%~ni.png" -o "%%~ni2.png"
"...\pngout.exe" "%%~ni2.png" "%%~ni3.png" )
So I'm dragging the images onto the .bat file, but only the images from the first folder would go through, the batch file ignores images from the subsequent folders. How can I fix that? Thanks.
for /f "tokens=*" %%i in ('dir *.png /s /b') do (
"pngquant.exe" --force --speed 1 --verbose "%%i" -o "%%~di%%~pi%%~ni2.png"
"pngout.exe" "%%~di%%~pi%%~ni2.png" "%%~di%%~pi%%~ni3.png" )
try this. but note that PNGs will be created in the same folders. don't know however if it was your intent.
Dropping files on the batch file is the same as providing them as arguments on the command line. Your script ignores its arguments and processes just its working directory.
Replace the for argument (*.png) with (%*), which contains the list of all arguments.
Also, instead of %%~ni, which returns just the name of the file, you'll need to say %%~dpni, to include the drive and path, if the files are not in the same folder as the script.

7-Zip Command-Line Help (Batch File)

I need to run 7-Zip from a batch file and perform a few tasks, I was wondering if it was possible. Here is my situation:
I have a folder "X:/Archived Backups/" that contains archives and sub-directories with archives.
Some of these archives also contain further archives.
I need to recursively scan the directory and sub-directories and 7-Zip to extract each archive to a folder by the same name (archive name).
I also need it to extract archives within archives within archives etc.
Finally, I need it to delete the archives when extracted (this includes the archives within archives) and only leave the extracted folders.
Is this possible? If so is it possible from the command line? How would I do it?
Many Thanks
:)
Test this to see if it does what you need - it should extract them to x:\extracted\path\filename folders.
It doesn't delete the archives because you have to test this first.
Check the path to 7z.exe first.
#echo off
set "location=x:\extracted"
md "%location%" 2>nul
for /r "X:\Archived Backups" %%a in (*.7z) do (
md "%location%\%%~pna"
pushd "%location%\%%~pna" && ("c:\program files\7-zip\7z.exe" x "%%a" & popd)
)
pause
You can use this post and this as starting points.
For iteration and testing directory:
FOR %%i IN (%VAR%) DO IF EXIST %%~si\NUL ECHO It's a directory
For files, check file extension and extract using 7-zip command :

Resources