Apple script to move files of a type - macos-catalina

I have a folder of approximately 1800~ .7z files. Some of them uncompress as a single file, some uncompress as a folder with several of the same type of file. If I were to uncompress all of them at the same time, what I end up with is a folder full of .7z files, folders containing multiple of a file type, and multiple single instances of that same file type.
What I would like to do is run a script that would take all of the same file types, from all containing folders below the main folder, and copy them to another specified folder. I unfortunately don't have really any experience with Apple Scripts and while this may be simple, it sounds insurmountable to me. Any input would be appreciated.

Related

Proper way to zip xlsx-file from directory using Info-Zip's Zip utility

I’m using Zip utility from the Info-Zip library to compress the tree of catalogs to get xlsx-file.
For that I’m using the next command:
zip -r -D res.xlsx source
source - contains the correct directory tree of the xlsx file.
But if you then look at the resulting file structure, the source directory will be included in the paths of all files and directories at the top level, and MS Office Excel will not be able to open this file. This is a well known problem. To avoid it zip.exe needs to be inside of the dest directory.
The problem is that I want to use the source code of this utility in my project, so this leads me to be unable to call my process, which will be responsible for compressing directories, to get xlsx files from these directories.
I’ve tried to find a place in the zip source code, where the parent catalog appending on the top-level happens. But seems
it is done implicitly.
Who can suggest how it can be done?

Adding a CSV file to a project in Visual Studio

I am working on a project where I have to read in serveral pre-existing CSV (dog.csv, horse.csv, etc.). I want to know how would I add these file into my project so that I may test to see if my print functions work (the code is written in c++). Would I have to copy and paste the files into the debugging folder or would I place it under the test folder of the project?
You can include the files in your project in whatever (sub)folder you wish by using Right click -> Add -> Existing Item. Then, right-click on each file and choose Properties. Set up "Copy to output directory" to "Copy if newer".
Then after build, your files will be copied into the bin/debug folder.
To read the file, you can just use:
System.IO.File.ReadAllText("dog.csv");
Another possible way is to add a file within project, right click and select properties, and then in Copy to Output Directory, select Copy always. This way, csv file will be automatically copied in your debug and release packages too.
string executableLocation = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location);
string csvLocation= Path.Combine(executableLocation, "file.csv");
Above code will read file location from bin directory where your csv file will be stored.
This link should help guide you how to add CSV files to a project.
If you wanted to do a down and dirty way you could just save the CSV's somewhere on your local machine, and then hard code the file path to that location.
Example:
c:\test\Dog.csv and then set that as a variable for whenever you need to read in the csv file.

How to make a .bat to move files in a folder to a different folder, based on a text file listing the files to be moved?

I have a lot of files in one folder that I want to move to another folder. I have the files I want moved listed in a text file. Is there a way I can make a .bat so the files listed in the text file get moved to another folder?
I found this https://superuser.com/questions/355584/how-to-delete-files-from-a-folder-using-a-list-of-file-names-in-windows where this code
for /f "delims=" %%f in (files_to_delete.txt) do del "%%f"
sort of does I want, meaning that the batch uses a text file to process files, except it deletes the files. How do I modify this code so the files are moved to another folder?
Another question, the above code deletes files without going through the recycling bin. So how do I modify the code so when it deletes, the files get moved to the recycling bin. If that happens, then I can easily drag it out to a new folder. I'm a newb using Windows 10. Thank you.

Zlib and Minizip - How to add a new directory to a .zip file

I have written an application to compress the contents of directory to a .zip file from C++, using zlib and minizip. Minizip is not well documented online but the file "zip.h" in the source code contains comments.
My application uses FindFirstFile and FindNextFile to get a list of all files (and subfolders) in the directory and then, as shown here How do I use Minizip (on Zlib)? creates a .zip file and opens new files within the .zip.
Then I read the source files with fopen and fread and write the contents to the newly created files in the .zip folder. This all works just fine if the directory to be compressed contains only files, and no subfolders, but I cannot decipher from the comments in the source code how I add a new folder to a .zip file and then write files to that folder.
As it turns out, you don't need to create a new directory in the .zip file as a separate step. You can just pass the parameter "foldername\filename.ext" to the zipOpenNewFileInZip method and it will create the "foldername" directory for you then add a new file "filename.ext" to that directory.

FinalBuilder Enumeration of files and folders

What's the best way to enumerate a set of files and folders using FinalBuilder?
The context of my question is, I want to compare a source folder with a destination folder, and replace any matching files in the destination folder that are older than the source folder.
Any suggestions?
ok, for future reference, it turns out that under the catgeory "Iterators" there are two very helpful actions.
File/Fileset Iterator
Folder Iterator
Further digging revealed the Robocopy Mirror action, which does exactly what I was looking for, namely syncing the destination folder with the source folder. No need to write my own file iteration routines.