untar files into single directory preserving the directory structure - tar

It is possible, and if so how, to use tar to extract a zip while preserving the directory structure? Currently it just extracts everything into a single directory using the path as the file name.
Example file name
Farlex.581429F59E1D8_1.5.1.9_neutral__wyegy4e46y996.main\Assets\buttons\add.png

Related

How can I rename files within a tar.gz file during extraction of the tar.gz file?

Simplified problem: I have a tar.gz file: Example.tar.gz
When extracted, it produces 1 folder named 2014, and 3 files within that folder named as follows:
a1:00:test
a2:00:test
a3:00:test
Objective: When extraction is complete, I want the folder to still be named 2014, but have the files within the folder named as follows:
a1-00-test
a2-00-test
a3-00-test
These files are on an ext4 file system, but the extracted contents must be on a ntfs file system which is not possible due to the illegal file names (:).
These tar.gz files are very large (30 GB), and I have over 70 of them. It would not be possible to extract all the files on the ext4 file system and rename them due to limited storage.
tar -xzvf /media/joshua/output/Example.tar.gz -C /media/joshua/elements/
Above code works normally, but not when extracting to the ntfs file system (due to illegal file name).
tar --transform='s/:/-/'-xzvf /media/joshua/output/Example.tar.gz -C /media/joshua/elements/
Above code suggested by #Barmar changes the first : to a - but not the second :
I have tried suggestions here: how to rename files you put into a tar archive using linux 'tar' but I am new to Linux and having some trouble understanding the syntax, and applying it to my situation. Any help or general suggestions is appreciated!
Use the --transform option as described in the question you linked to:
tar --transform='s/:/-/g' -xzvf /media/joshua/output/Example.tar.gz -C /media/joshua/elements/
s/:/-/ replaces : with - in the filename.

Can you use .\swagger-codegen-cli.jar generate to generate files that are not located in the same folder as swagger-codegen-cli?

Using java -jar .\swagger-codegen-cli.jar generate -l typescript-angular -i .\swagger.json, I can turn ".\swagger.json" into a typescript-angular file. However, the .json file must be in the same folder as the swagger-codegen-cli, which is impractical when you have many files to convert (You have to manually download and move every file). I've scoured the web, but haven't been able to find a practical solution. Is there a way to do this? Am I able to integrate swagger-codegen in such a way that I can "mass produce" files? I know I can change the output directory (-o) but that isn't what I'm looking for. Say I have a folder called "scripts" where I've got a lot of .json files. Am I able to call swagger-codegen-cli generate on any file inside of that folder, even if swagger-codegen-cli is located in a different folder?
The -i argument expects a fully-qualified or relative path to an OpenAPI file, or an URL where that file is located. That is, the file does not have to be in the same folder as the Swagger Codegen CLI.
Examples:
# The file is in the current working folder
-i swagger.json
-i ./swagger.json
# The file is in a subfolder of the current working folder
-i sub/folder/swagger.json
-i ./sub/folder/swagger.json
# Relative path to a file in another folder
-i ../../path/to/swagger.json
# Absolute path - Windows
-i C:/path/to/swagger.json
# Absolute path - *nix
-i ~/path/to/swagger.json
# URL
-i https://petstore.swagger.io/v2/swagger.json

How to copy multiple directories into a single directory and preserve directory structure

I would like to copy multiple directories (with contents) to a single directory in my container while maintaining the original directory structure of my project. For example, the relevant line in my Dockerfile looks like this:
COPY bin env project ./projects/
The command above only copies files into my projects directory and also removes all of the original directory structure of bin, env, and project.
How can I copy several directories (with contents) such that the original directory structures are preserved? I did find this reference, but as the first commenter points out, directory structure is lost with this method.
you need to create the directory structure since COPY will only add files not the directory itself.
one approach will be aading them one by one.
RUN mkdir -p projects/{bin,env,project}
COPY bin projects/
COPY env projects/
COPY project projects/
or maybe using ADD will be a better approach since Add will decompress archives download files and more.
so you will need to archive directories first, then use add like below
ADD archive.tgz projects/

How to set output directory for QMake generated vcproj files

Is there anyway to modify the path where *.vcproj (and *.vcxproj, *.sln...) files generated by QMake are written ?
I do not want to modify the path of the generated *.exe or *.dll file. I'm looking for a way to create the *.vcproj file out of my sources directory, to keep it clean from any generated file.
I'm using Qt 5.5.
Thanks
EDIT :
By default, QMake generate a .sln/.vcproj file next to the *.pro file (in the same directory). I'm looking for a way to generate the .sln/.vcproj file elsewhere.

Extracting a zip file to dynamic destination folder in Ruby on Rails

Well,I am using Rails 2.02 and ruby 1.8.6 in my application,I need to provide a feature to extract the zip file into dynamic destination folders.i.e Destination folder name is fixed based on that it has to search on PC for that folder and extract zip file into that PC.
For example,
In PC1 the destination folder path is C:/sites/myfolder
In PC2 the destination folder path is D:/demo/for/myfolder
In PC3 the destination folder path is C:/myfolder
In PC4 the destination folder path is F:/path/to/myfolder
Here,In this example my destination folder is myfolder,so in the above four cases the path is different for that.What I need was my rails application should search for the folder in pc and extract zip file into that.
Thanks for the help!

Resources