ApplScript to compress folder? - macos

What is the AppleScript to compress a folder? Not let the user select a folder from the dialog but give the folder path on a string variable. The script I know compresses the folder with the full path as folder. For example: if the folder names "ABC" is in this folder location, "Applications:Data:Level" then the compressed folder will create the folder structure like this "Applications:Data:Level:ABC" and put the content. I do not want this one. The compress ApplScript must not maintain this folder structure.
?

If you use zip, cd to the parent directory of the zipped directory first:
do shell script "cd /usr/share; zip /tmp/dict.zip -r dict"
There are no AppleScript commands for creating archives, and Archive Utility is not scriptable.

Related

How to move a file into a subdirectory with bash?

so I'm having trouble with moving my file into a subdirectory. Right now I have a jpg file in my Downloads folder that I want to move over to my images folder, which is contained inside my Desktop and odin-links-and-images folders. Just for a bit of clarification, my Downloads folder is a completely separate directory, and I want to move the jpg file inside my Downloads folder to
Desktop/odin-links-and-images/images
What I've tried so far is doing the following command inside my Downloads directory:
mv dog.jpg images/
Doing this, I ended up getting the error:
mv: cannot move 'dog.jpg' to 'images/': Not a directory
I assume this is because my dog.jpg file is in my Downloads folder, which is a completely separate directory from my Desktop/odin-links-and-images/images directory. I'm not sure if it's possible to move my jpg file, but I'd appreciate any guidance on how to do this!
Write the complete path to images:
mv dog.jpg ~/Desktop/odin-links-and-images/images
This is assuming Desktop is in home. Otherwise, use whatever is the full path to desktop.

How to move all files within subfolders into a new folder using bash?

I have a folder that I downloaded all my fonts to. When I opened the folder i noticed they were saved out into subfolders.
Is there a bash-shell script to grab all the files within the subfolders and move them to the parent folder?
You can move files with same extensions recursively using the wildcards. e.g. if you want to move all log files in nested folders under log/ directory into backup/ directory, you can use the following command:
mv log/**/*.log backup/

Script which copies original files from shortcut paths

I have a folder that has subfolders with some files that are shortcuts to their original file in a different location outside these main folder. I need to write a script (Windows preferably) that parses through each subfolder and goes to each folder from the shortcuts target path and copies the original file into a specific folder.
In the end I want a folder with a copy of all the original files that were shortcuts from my subfolders.
Is this possible? Thank you so much!

Add folder contents to .rar through console commands without adding folder itself

Here's a question:
I have a folder named Root and it contains some files and folders. Using Winrar console commands, I need to create an archive Root.rar that should contain entire file/folder structure of Root and SHOULDN'T contain Root folder itself.
For example:
On drive:
Root-
|-SomeFile
|-SomeFolder-
|-SomeOtherFile
In the Root.rar archive:
SomeFile
SomeFolder-
|-SomeOtherFile
I tried to do this:
"C:\Program Files\WinRAR\winrar.exe" a -r Root.rar Root\*
But it also adds the Root folder.
Then I tried this:
"C:\Program Files\WinRAR\winrar.exe" a -ep -r Root.rar Root\*
In this case winrar didn't add the Root folder, but it also didn't add any other folders, and instead of folder tree I've got a bunch of unstructured files. Is there any way of adding the folder structure, ignoring the Root?
Thank you!
Use -ep1 (exclude base folder names) instead of -ep (exclude paths from names)

Shell script to move several files to a different directory

I have two subdomains of a website and in both accounts one folder is there with several sub folders. It's a photo folder. In dirA.xyz.com photo folder consists of several folders and sub folders and in dirB.xyz.com photo folder consists of new photos which are not available in dirA. But the sub folder name in dirA photo folder may be the same as dirB photo folder but the final name of image will be different. So I want to move all files of dirB photo folder to dirA photo folder without deleting the dirA photo folder data.
As the name and folder structure varies and data is in millions how to move them and merge so that all data remains?
I've tried using zip. I zipped the photo folder of dirB, moved it to dirA and tried to unzip it but it's not going in dirA photo folder, it's going in dirB photo folder. I've tried changing the owner of dirB photo folder to dirA owner but it also did not work. The only thing that is working is the move command so how can I achieve this with mv?
mv /home/xyz/public_html/photo/ABC/Something/something/xyz.jpg /home/ABCDE/public_html/photo/ABC/Something/something/xyz.jpg
All files are jpeg or png.
Sounds like you need rsync, with the merge option, not overwrite. If you are using any decent and recent version of linux, you should have rsync installed by default.
source: /home/xyz/public_html/photo/ABC/Something/something/xyz.jpg
target: /home/ABCDE/public_html/photo/ABC/Something/something/xyz.jpg
rsync -avibu --ignore-existing /home/xyz/public_html/photo/ /home/ABCDE/public_html/photo
On this command I selected the top level directory randomly. You may want to modify according to your needs. Also pay attention to the trailing "/" on both source and destination. Otherwise, placement of files might be a level of directory off.
-b makes rsync backup files that exist in both folders, appending ~ to the old file. You can change the ~ suffix with --suffix string_of_your_choice
-u makes rsync transfer skip files which are newer in destination than those in source

Resources