How to add new text file in zip file using ruby - ruby

Is it possible to add a new text file in the zip file without extracting the zip file using ruby?

Related

How to add a file to a .gz archive and delete the original file?

My files name is <09/12/2020>_master. How would I be able to add this file to a .gz archive and then remove the original file?
GZip isn't an archive format, it's a compression format. A .gz file can only contain one compressed file; if you need to put more than one file in at a time, you'll need to pair it with an archive format (such as tar).

Shell Script to Convert CSV to Text File

I need to create a shell script that reads a different folder based on today's date and inside the folder contains multiple files and one csv file that will have unique name everyday that is tab delimited. I want to pull this file and resave it as a text file.
Example of file path:
data/model/output20190725 (folder contains multiple files, new folder is created everyday)
-logfile1
-logfile2
-part3983isis4838.csv (this csv file will have a new and randomly generated name everyday, the csv file is also tab delimited)
I know how to go from a csv file to a text file, but I don't know how to add the logic of the folder name and the csv name changing everyday.
I saw that I could possibly use grep, but I don't know how to navigate to today's date folder and pull the csv and pass to the next argument to make the conversion.
grep -l .csv * |

Bash Script to read CSV file and search directory for files to copy

I'm working on creating bash script to read a CSV file (comma delineated). The file contains parts of names for files in another directory. I then need to take these names and use them to search the directory and copy the correct files to a new folder.
I am able to read the csv file. However, csv file only contains part of the file names so I need to use wildcards to search the directory for the files. I have been unable to get the wildcards to work within the directory.
CSV File Format (in notepad):
12
13
14
15
Example file names in target directory:
IXI12_asfds.nii
IXI13_asdscds.nii
IXI14_aswe32fds.nii
IXI15_asf432ds.nii
The prefix to all of the files is the same: IXI. The csv file contains the unique numbers for each target file which appear right after the prefix. The middle portion of the filenames are unique to each file.
#!/bin/bash
# CSV file with comma delineated numbers.
# CSV file only contains part of the file name. Need to add IXI to the
beginning, and search with a wildcard at the end.
input="CSV_file.csv"
while IFS=',' read -r file_name1
do
name=(IXI$file_name1)
cp $name*.nii /newfolder
done < "$input"
The error I keep getting is saying that no folder with the appropriate name is able to be identified.

How to extract office2003 ppt file with using Tika?

I have some office2003 .ppt files.In these files there are some embedded files,I want to extract them from ppt file.However,using tika-app-1.16.jar for that only extract some .wmf picture files.So what i should do to extract file from .ppt?

Read the content of the only file in a zip file in Ruby

I have a zip file in Ruby at a particular location on the file system. There is only 1 file in that zip file. I want to read the content of that file. How can I do it (without knowing the name of the file up-front)? I've tried looking at various libraries/ways but the APIs were either outdated, or the libraries weren't maintained for years.
You can use RubyZip:
require 'zip'
a = Zip::File.open(path_to_zip_file) { |z| z.first.get_input_stream.read }

Resources