top of page
Search
viportbunsa1978

Linux Zip Rename File In Archive



I need to rename all the files on a zip file from AAAAA-filename.txt to BBBBB-filename.txt, and I want to know if I can automate this task without having to extract all files, rename and then zip again. Unzipping one at a time, renaming and zipping again is acceptable.


Since I don't really care about the filename an acceptable solution would be to rename the file, or write the contents to a file named something else than the name specified in the archive. Is that possible with a common command line zip utility? If so, how. Other suggestions on what may be wrong (perhaps it's not the zip utility) are also welcome.




linux zip rename file in archive



If I try to extract on the command line, I get the error "File name too long".If I use the graphical archive manager it will not extract the files and it will not let me rename them. The same problem occurs if I mount the archive.


There is no undo function for any of the changes you make with zipnote, so double check your comments file before writing to the archive! Any changes you make with the -w option are permanent.


The mv command has a purpose in life, and that is to move files. It is a happy side effect that it can be used to move an existing file into a new file, with a new name. The net effect is to rename the file, so we get what we want. But mv is not a dedicated file renaming tool.


The middle part defines the work we want to be done on each filename. The s means substitute. The first term (.prog) is what rename will search for in each filename and the second term (.prg) is what it will be substituted with.


I have to rename all files in an archive, about 30000 files.Since the command line would be to long in this scenario: Is it possible to do the rename with a list file containing all source and destination names?


Using command line with an automated zip-server we created. Often with lots of large files. Files are stored with UNIQUE ID's for their names, but we must rename to the original file names. Files are too big to rename before zipping, and the RN command seems to force a complete WRITE of the zip for each RN command.


I need a folder to be checked (event triggered) if there are is are new .zip files created in it. If there are new .zip files, the flow has to grab every .zip file one by one and extract its content to the same folder and rename the extracted file(s) to the format yyyy-mm-dd-hh-mm-ss-originalfilename.ext. Afterwards the source .zip file is no longer needed and has to be deleted (alternatively it could be moved to a temp folder), then the next .zip file has to be gone through the same process of being extracted, files renamed with date in its name and the source .zip has to be deleted until every .zip in the folder got deleted and their files have been extracted and renamed.


Quite a fun one this. I have a folder call ZIPs on my OneDrive and if I drop a zip into it, it will extract, delete and then rename the files in a new folder called ZIPs/Renamed. I have included a Copy/Paste solution for you below. You can copy and paste this into your Cloud Flow - all you need is the when file is created in One Drive trigger and update the Compose Action with the name of your Folder for Zips that needs monitored (first compose) and also List Files in Folder Path as it needs a folder ID. Make sure you create a Renamed folder too.


Taking the example above, to rename the downloaded file with wget command to something else, you can use the -O or --output-document flag with the -c or --continue options helps to continue getting a partially-downloaded file as we explained at the start.


I have a zip file named: youtube_videos.csv.zip and I would like to unzip it to a certain folder called target and rename the file in that folder to youtube-videos.csv. I have it, but in two lines as below:


When you add or extract files, the target archive or directory may already contain files that have the same names as the files you are adding or extracting. Use the overwrite option to tell PKZIP how to proceed.


When you add files to an existing archive, PKZIP will, by default, overwrite files with the same name. You must use overwrite with your preferred sub-option to preserve existing files.


Perhaps you've received an archive with one or more encrypted files. Before you can decrypt it, you need to know how it was encrypted. Use VerifyEncryption to determine the type of encryption used. Whether you're creating an encrypted archive manually or with a script, you may also need to check whether an archive, or files in that archive, were encrypted, and how to decrypt them. This option will help as well.


Use VerifyRecipient to determine whether an archive, or files inside an archive, was encrypted for a specified person. Identify the X.509 certificate or OpenPGP key associated with the intended recipient.


The rename option renames files when you add or extract them. Used with the add command, the option renames files that you add so that they have a different name in the archive from their original name outside the archive. Used with the extract command, the option renames files as you extract them to give the extracted copies a different name from the name they have in the archive.


The rename option uses regular expressions and operates on both pathnames and file names. Regular expressions are a widely used methodology for transforming strings of symbols, such as text characters, by looking for specified patterns of symbols and replacing any matches with new patterns.


For example, the command line below archives all text files in the directory and renames the archived copies of any that have the string blue anywhere in their name so that blue is replaced with green.


For example, PKZIP can read data from standard input (STDIN) and add it to an archive. To tell PKZIP to get data from STDIN, a hyphen is used in place of a file name in the command line, and the data is referenced by a hyphen, not a file name, in the archive. Using the rename option, you can replace the hyphen with a file name when adding the data.


The command line above runs some program and pipes its output to PKZIP. PKZIP gets the data from STDIN (the hyphen at the end), renames it by replacing the hyphen with a file name, and archives the data under the file name.


You can use rename multiple times in a command line. PKZIP attempts all the specified replacements, in the order given, on all added or extracted files. For example, the command line below first replaces blue with green in all files and then replaces txt with doc in all files.


The command line above renames *.txt files to *.doc files, but it also replaces any occurrences of txt that are not at the end of the file name. For example, a file named txture.txt is renamed to docure.doc. Regular expression syntax provides metasymbols to help you deal with this sort of situation by specifying position, variables, and quantifiers.


The shortname option enables you to convert file names in long file name format to DOS-format short (8+3) file names on the copies of the files added to an archive. Use shortname with the dos sub-option, or no sub-option at all, to specify DOS format:


Construct the timestamp using tokens (replaceable elements) from the table below. When embedded in an archive file name, the tokens serve as named parameters. The substitution option causes PKZIP to replace the tokens with the corresponding values listed in the table. (If the substitution option does not appear in the command line, the tokens become literal parts of the file name.)


The preceding command line causes each file zipped from the myfiles directory to be added to its own archive in a directory named newzips 2014-08-09-12-06-29am.zip if the date and time are August 09, 2014 12:06:29 a.m.


PKZIP issues an error or a warning when it encounters a problem or unexpected condition. In general, PKZIP issues a warning when the condition does not prevent PKZIP from completing its operation, and an error when it does. For example, PKZIP issues a warning if a digitally signed file in an archive cannot be authenticated; this condition does not prevent PKZIP from extracting the file. PKZIP issues an error if it cannot find a specified archive or is unable to open it.


When you enter the fix command, PKZIP prompts you to enter a new ZIP file name. The example above used test1ZIP. If you do not enter a file name, the name pkfixed.ZIP is used. PKZIP scans the original file, attempts to repair the archive, and saves the updated file with the new name. The original, damaged file is not updated.


Note: The fix command can only fix ZIP archives that are physical files. It cannot fix ZIP archives read from STDIN or special files (named pipes, sockets). Nor can it output fixed archives to such targets.


The temp option enables you to specify an alternate location for the temporary file that PKZIP needs to create to update an existing ZIP file or create a spanned archive. PKZIP also creates a temporary file when writing an archive to a data stream (see "Writing an Archive to STDOUT and Special Files").


In the case of an archive written to a data stream, PKZIP compresses and encrypts the data (if encryption is specified) before writing it to the temporary file, so no security vulnerability is created. The temporary file is needed to get size information for local headers, which are written out before file data. 2ff7e9595c


0 views0 comments

Recent Posts

See All

Comments


bottom of page