How to look at the contents of a zipped folder in batch? - batch-file

In this case, I have a zip folder with contents inside. How would I look into the zip folder and be able to check the file name of those files for a certain word without having to unzip the file to begin with?
So for example:
I have a zip folder with the files inside named
123456789COW.txt
123445614COW.txt
123456789ASK.txt
232436787CAT.txt
and I want to check if the file has COW inside the name.
Every solution I have found so far has assumed I know the contents already, but in my case that may not always be true and I need to check.

Related

How to zip multiple datasets from different folders in one zip file SAS

I have a macro that creates a zip file to archive all datasets from ONE folder. I would also like to also include only a few datasets from a different folder into that same zip file, if possible?
I'm using an already built out macro call 'zip(path, zip name, ziplock);' which will create a zip file from a folder. How can I add other datasets from another folder in that zip file without moving the datasets into that folder manually after.
The macro parameters are defined below:
path = file path of directory to be zipped
zip name = name of new zip file
ziplock = location of new zip file
I would like to zip an entire folder AND a few datasets from another folder
It's not possible to answer for your macro without seeing the macro, but there are ways to zip files in SAS, and here's one.
https://blogs.sas.com/content/sasdummy/2016/03/04/add-files-to-a-zip-archive-with-filename-zip/
Basically, you use a filename to the zip file:
filename zipfile "\\path\to\zipfile.zip";
Then you make a specific filename to the member inside the zipfile:
filename newfile zip "\\path\to\zipfile.zip" member="path\to\sasfile.sas7bdat";
Then you use byte-wise streaming to copy the file in. From the above post with minor edits:
data _null_;
infile data_fn recfm=n;
file newfile recfm=n;
input byte $char1. #;
put byte $char1. #;
run;
data_fn is the actual physical filename of the sas dataset you are adding.
This works fine with files from different folders, so you can easily use this for whatever you want.

Navigating a Zipped Filesystem

I have found that, with some file zippers like 7-Zip, it is possible to use files inside the created archives. For example, if I create a file my-zip-file.7z, containing folder my-folder, with files this-file.docx and that-file.html I can use 7zip to go into my-zip-file.7z and open the 2 files, and see or change the contents, even if the original my-folder is deleted! How is this possible?
If you look at the file path for whatever you're editing you'll see that the document is saved to a temporary folder. When you save (or possibly close) 7-Zip then updates the zip file with the saved content.

Need to copy and rename files in different folders

would anyone know how to write a batch file (or two) that would:
copy hundreds of "index.html" files that are in different folders and keep within the same folder (so needs to search within sub folders)
rename the copies (keep the originals as is) to "index.jpg"
could anyone help?
I used a bulk rename tool to rename all index.html files to index.jpg in a copy of the main folder, then used robocopy to copy everything over, including the file structure back to the original folder (leaving the index.html's alone)

copy to output directory file delete

i find that to play video files using mediaelement, we need to set the file's Copy To Ouput Directory to Copy Always. is there any option to auto delete the file from the output directory after it has been used? because if there's hundreds of video that has been played by the application, then it will take a massive amount of storage, right? because from what i seen, this copy to ouput directory will create the duplicate of the files, from it's original source path. please enlighten me
You do not need to copy the files to the output directory, you can set the source as follows:
mediaElement.Source = new Uri (System.IO.Path.Combine(dirWithVids, fileName)
,UriKind.RelativeOrAbsolute)

How to exclude a specific file from being copied using xcopy

I'm new to Windows batch files, but I'm writing a .bat file that just copies a bunch of files from one place to another maintaining the file directory structure. Using xcopy this is simple but I need to exclude some files from being copied. You can use /exclude and create a text file full of strings that you want to be excluded, but this doesn't just exclude files with the exact names in the text file, it excludes all files whose filenames contain any of the strings in the text file.
What this means is, if I want to exclude any files named 123.txt and put this string in my exclusions text file, if there was a file called 1123.txt anywhere in the source folder or any of its subfolders that would also be excluded.
How can I exclude only files with a specific filename from being copied?
Evening Bill.
Can you add a slash before each file name? That should work
EG
instead of
123.txt
blah.txt
use
\123.txt
\blah.txt
Try creating a temporary folder, xcopying all of the files into that folder, deleting the ones you don't want, then xcopying those to the final destination. Finally, delete the temporary folder and its contents with rd xyzzy /q/s

Resources