How to add files/folders to multiple zip files at once with WinRAR? - zip

Is there any way to add files/folders to multiple zip files at once. For example:
Updates:
folder1
folder2
file1
file2
Archives:
archive1.zip
archive2.zip
archive3.zip
I need to add updates to all archives without opening all of them and pasting updates in there.
Any way to do this?
Or is there another archive program that can do this?

This can be done using a batch file and for example WinRAR.
#echo off
if not exist archive*.zip (
echo There are no archive*.zip files to update in
echo.
echo %CD%
echo.
pause
goto :EOF
)
set "ErrorCount=0"
for %%I in (archive*.zip) do (
"%ProgramFiles%\WinRAR\WinRar.exe" u -afzip -cfg- -ep1 -ibck -inul -r -y "%%I" folder1 folder2 file1 file2
if errorlevel 1 (
echo Error on updating %%I
set /A ErrorCount+=1
)
)
if not "%ErrorCount%" == "0" (
echo.
pause
)
set "ErrorCount="
For each archive*.zip file WinRAR is called to update the ZIP file with the two folders and the two files.
The batch processing finishes without printing any message and without pausing if all ZIP files found could be updated successfully. Otherwise the batch file outputs which ZIP file could not be updated for example because of read-only attribute set, and pauses the batch processing before finishing so that the user can read the error message(s).
For details on the WinRAR command u and the used switches open in WinRAR from menu Help the Help topics, open on tab Contents the item Command line mode and read at least the help pages:
Command line syntax
Commands - Alphabetic commands list
Switches - Alphabetic switches list
For understanding the other used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
echo /?
for /?
goto /?
if /?
pause /?
set /?

You can do it by using 7zip command line version
7z a archive1.zip dir\ -v10k -v15k -v2m #listfile.txt
this will do archive all files and folder is in that folder named 'dir'
and first volume will be 10kb, second will be 15kb and others will be 2mb each except last
and you can use a file that has list of all files named.

Related

Possible to make a backup of original file in vim?

Is it is possible to make a copy of original file before writing the new buffer to the file without having to leave vim and copy it manually?
How about this? After editing the file, before :wq, you can do:
:!cat myfile.txt > backup.txt
and then save using :wq. The previous content would be stored in backup.txt
UPDATE
I realized that my solution might be a little complicated for beginners and unnecessary for single files backups, so if you want a simple solution just use:
:!cp % ~/
The % register keeps the name of the file and with this extern command you can copy the current file to your home folder or you can change it to any folder you want.
In Windows you can use this to send to a backup folder on C::
:!copy % \backups\
You can turn in a shortcut on your .vimrc with something like:
nnoremap .b :!cp % ~/
Old Answer:
I had the same need to backup before save the modifications, so I created a Bash and a Batch(for Windows) file that backups all the files that I want and used this conditional statement on .vimrc to choose automatically between the two systems:
if has("win32")
nnoremap <leader>bc :! C:\C\SCRIPTS\backupWIN.bat<cr>
else
nnoremap <leader>bc :!bash /home/vini/C/SCRIPTS/backup.sh<cr>
endif
Here the code for the Bash version:
#!/bin/bash
#adds the date to folder(you can change the date format)
now=$(date +"%d_%m_%Y_%H;%M;%S")
mkdir /home/vini/backups/C_BKP/pre_alpha/$now
cp -r /home/vini/C /home/vini/backups/C_BKP/pre_alpha/$now
echo "saved in: /home/vini/backups/C_BKP/pre_alpha/"$now
Here the code for the Batch file:
set start=%time%
::I didn't managed to make it print the seconds, so I choose to
::override the same files if I save twice in the same minute
#echo off
For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set mydate=%%a-%%b-%%c)
For /f "tokens=1-4 delims=/:" %%a in ('time /t') do (set mytime=%%ah%%bm%%c)
mkdir C:\Users\vini\Desktop\C\C-%mydate%-%mytime%
::careful with xcopy , read the documentation before modify it
xcopy /E /Y C:\C C:\Users\vini\Desktop\C\C-%mydate%-%mytime%\
You just need to change the name of the directories for match your folders and you are good to go.
As #Sato Katsura pointed out, it is patchmode:
:set patchmode=.orig
I just simply use:
:!cp % %.backup
Which will create a new file in the same location with .backup appended to it.

Search for a file and open the path in CMD

I would like to achieve the following in CMD:
Will search for a specific filename - This I know how to do, with dir /s filename
Once found it will bring me to that path.
Example: I am now on C:\, if that file was found in C:\test then it will open C:\test in command prompt.
Alternatively, I would like just to copy the found file to a path I will specify. I just don't know how to do it, since I don't know the path where the file will be stored (it's different every time).
Thanks in advance!
I'm a liitle confused with your question but I will try to walk you through a batch code I wrote to help you with this.
dir /b /s "test.txt" > "%userprofile%/Desktop/result.txt"
::find the file path to the file you want to find and insert it in a .txt file
::you made called result.txt (also %userprofile% is a variable that brings you to
::your user directory ex C:/users/admin)
for /F "tokens=*" %%A in (%userprofile%/desktop/result.txt) do (
set var1=%%A
)
::set the variable var1 equal to the first (well... only) line in the file.
::I could explain what that for loop means in detail but just remember that %%A
::is a variable set from what was found when looping through the result.txt.
xcopy /s "%var1%" "C:/wherever/you/want/it/to/go"
did this help??

Move 300 images from a folder (contains 800 images) to another based on file name list

I need to move 300 images from a folder (contains 800 images) to another folder. The file name list of these 300 images are available in the excel format. Is it possible to move them via programming instead of search the file and move it one by one? Our IT told me he can't separate these files. Do you have any solution? Many thanks in advance!!!
Here's one way of doing this - I am assuming you are on Windows. First, save text file called ListOfImages.txt that contains the names of the images you wish to move - put one image on each line and include the extension. Then, save the following into a file called movefiles.cmd:
#echo off
set Source=C:\Users\YourName\Desktop\moving\MovingFrom
set Target=C:\Users\YourName\Desktop\moving\MovingTo
set FileList=C:\Users\YourName\Desktop\moving\ListOfImages.txt
echo.
if not exist "%Source%" echo Source folder "%Source%" not found & goto Exit
if not exist "%FileList%" echo File list "%FileList%" not found & goto Exit
if not exist "%Target%" md "%Target%"
for /F "delims=" %%a in ('type "%FileList%"') do move "%Source%\%%a" "%Target%"
:Exit
echo.
echo press the Space Bar to close this window.
pause > nul
You will want to change the variables for Source, Target, and FileList to match where you have those folders and the ListOfImages.txt on your machine. After you have saved this file (make sure it has the .cmd extension, you should be able to double-click it and it will run the commands in your Command Prompt.
For example, say my MovingFrom folder contains the following:
And I only want to move Image1.png and Image2.png -- then my ListOfImages.txt file would like this:
After running moveFiles.cmd (provided I have changed the necessary variables to point to the right folders/places on my machine), my MovingTo folder should contain the following:
Notice that Image2.png was not moved because it was not listed in the ListOfImages.txt text file.

move files name in excel to a specific folder

I am trying to write a batch file that reads from excel file. then move them to a specique folder.
lets say in the excel , there are:
111.txt
222.txt
333.txt
512.txt
I want a batch file that move files into a specific directory that have the above names.
how can I achieve that ?
(I am using xp , and I the directory is D:)
cd /d "d:\files"
for /f %%i in ("C:\where the file resides\file.csv") do (
echo move "%%i" "D:\New\"
)
remove the echo if output seems ok

I would like a script to search within text files a certain pattern of strings and move those files to another directory

I need to know how to perform an advanced search on a text file using tools like notepad++, freecommander and windows if possible. A bat script file will be great.
The problem is that i need to search through about 1000 txt files in a directory. I need to know form those 1000 txt files which have a string in the form of for example "SYR_SHA/245/4". I just want it search for the pattern for example *****_******/*****/****** where * are characters that can change in number.
There must be an _ between the first and second set of characters as seen above in the example.
the script should go through the entire txt file and search for the above pattern. The script should then Move all the results in to a seperate directory
Many Thanks
Create this batch file and copy it into your folder where you have all the 1000 .txt files
Change the yourdestinationdirectory directory and run the batch file
#Echo Off
FindStr /M /R "[a-zA-Z]*_[a-zA-Z]*\/[0-9]*\/[0-9]*" *.Txt > findstr.out
For /F "tokens=*" %%a In (FindStr.out) Do call :move_Rtns %%a
del FindStr.out
Exit /B
:move_rtns
copy %1 yourdestinationdirectory\*
del /Q %1
Exit /B
Please change the Regex according to your requirement, for eg. If you are expecting number and letter together you can replace [a-zA-z] with [a-zA-Z0-9]
Good luck

Resources