I have in a single folder pairs of files with the same filename and different extension.
ex.:
filename1.txt
filename1.docx
filename2.txt
filename2.docx
filename3.txt
filename3.docx
filename4.txt
filename4.docx
etc...
I would like to select all those files and put the pairs in separate zip files.
ex.:
filename1.zip (containing "filename1.txt" and "filename1.docx")
filename2.zip (containing "filename2.txt" and "filename2.docx")
filename3.zip (containing "filename3.txt" and "filename3.docx")
filename4.zip (containing "filename4.txt" and "filename4.docx")
filename5.zip (containing "filename5.txt" and "filename5.docx")
etc...
Is that even possible using 7-zip command line and a prepared batch file?
Double the % to %% for use in a batch file.
FOR %f in (*.txt) DO 7za a "%~nf.zip" "%~nf.txt" "%~nf.docx"
Related
I am using PDFtk-server to merge 2 PDF files. This creates a new PDF with name Test_.
Now, what I am looking for is a batch files that renames the Test_ files to Test_datestamp and then move them into another folder and delete the files.
It is working if only one file is present.
pdftk C:\test\*.pdf C:\test\file-to-add\file.pdf cat output C:\test\output\Test_.pdf
ren "C:\test\output\*pdf" "Test_ - %date:/=.% %time::=-%.pdf"
del C:\test\*.pdf
Then comes to copy part to other folders.
If having multiple files, the first one gets renamed but other not, because it is trying to set the same timestamp, so I need some kind of delay between renaming.
I have 324 files. The format of the file names is: 1.fa.abc.txt, 1.fa.de.txt, 1.fa.zen.txt and 2.fa.abc.txt, 2.fa.de.txt, 2.fa.zen.txt and 105.fa.abc.txt, 105.fa.de.txt,105.fa.zen.txt. All of these files are in the same folder. I want to merge all the files with the same prefix (the numbers in the prefix, in this case). Is there a quick way to do it?
This code in a bat file will merge all the files with the same prefix from 1 to 324, storing every merged file (from the prefix) in a different result.txt:
FOR /L %%G IN (1,1,324) DO copy %%G*.* %%Gresult.txt
I have two folders:
\txt
\pdf
I have batch converted *.txt files from \txt\*.txt to \pdf\*.pdf.
\txt has 6000 files.
\pdf has 5950 files.
How can I use a Windows batch file to list the 50 files not in pdf, so that I can check why the conversion failed on these 50 files?
In essence: two directories should have files with the same file names, but a different file extension. List the 'missing' file names.
for %t in (\txt\*.txt) do if not exist "\pdf\%~nt.pdf" >>missing.txt echo %t
(from the prompt)
Please can someone help with the below
I have two folders:
C:\FolderA
C:\FolderB
Folder A contains a bunch of files like an archive
Folder B contains the same bunch of files with the same name, however some data within the files may be different.
I want to write a .bat file which uses the diff command to compare all the files from folder A to the files in folder B with the corresponding name (e.g. update0001 against update 0001) and outputs the difference in "C:\Folder C" with each file difference in a separate text output. (e.g one file is called “Error update0001” and another “Error Update0005”
This is a simple way to check the files in two folders and give results.
fc /b "c:\folder a\*.*" "c:\folder b\*.*" >"c:\folder c\results.txt"
Hi, I have many zip files located at g:\toto. These zips contain some files. I would like to extract all zip in a same directory (g:\toto\extracted) then rename various files of the zip.
Example 1 :
www_12567.vp.zip : 3 files : alpha.doc, beta.xls, teta.doc
I would like after extraction, files are renamed with the name of the zip
www_12567.vp.alpha.doc, www_12567.vp.beta.xls, www_12567.vp.teta.doc
Example 2 :
www_12.vp.zip : 3 files : al.doc, bea.xls, tta.doc
www_12.vp.al.doc, www_12.vp.bea.xls, www_12.vp.tta.doc
I found this question, but it talks about .txt and the zip contain one file, so, it doesn't work.
Without knowing the contents of the archive you can't know which files to rename, because you are putting them into a directory that may already contain other files.
This, however, would be much easier if there was a dedicated directory to put the files temporarily. Here's how you could use it:
#ECHO OFF
SET "srcdir=G:\toto"
SET "tgtdir=G:\toto\extracted"
SET "tmpdir=G:\toto\extracted-tmp"
FOR %%Z IN ("%srcdir%\*.zip") DO (
unpack "%%Z" with your favourite tool into "%tmpdir%"
FOR %%I IN ("%tmpdir%\*") DO MOVE "%%I" "%tgtdir%\%%~nZ.%%~nxI"
)
Of course, the temporary directory would need to be empty before running the batch file. You could add DEL "%tmpdir%\*" somewhere before the loop to make sure it is.
One other note is, the above assumes that the archives do not contain subdirectories or, at least, that the files are extracted without subdirectories.
UPDATE
If you are using the 7-Zip archiver to work with .zip files, then this is how your extract command might look:
7z e "%%Z" -o"%tmpdir%"
Disclaimer: I'm not an active user of 7-Zip. This is what I used as a reference to come up with the above command:
7-Zip Command-Line Examples