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

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)

Related

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/

Copy command in Mac Terminal fails with "No such file or directory"

This should be straightforward, but I'm getting weird results.
I have a folder with subfolders containing ~4000 files. I'm trying to copy just the files of a certain filetype to another folder, while preserving the subfolder hierarchy.
Command:
cp -R /Users/Steve/Desktop/Hardscapes/*.LOB /Users/Steve/Desktop/Temp
fails with the message:
"/Users/Steve/Desktop/Hardscapes/*.LOB: No such file or directory".
I created the command by typing cp -R then dragging the source folder to the terminal window, adding *.LOB after the /, and dragging the destination folder to the terminal window.
Troubleshooting:
replacing *.LOB with *.* gives the same error.
cp -R /Users/Steve/Desktop/Hardscapes/ /Users/Steve/Desktop/Temp copies the entire Hardscapes folder to Temp, with all its subfolders and files.
Thanks for your help and suggestions.
EDIT: The folder Hardscapes contains only other folders. If I run the command above using one of those folders as the source, the contents are copied faithfully. The folder Hardscapes itself contains no .LOB files - they're only in the subfolders.
So maybe that's the issue, cp can't find any files corresponding to Hardscapes/*.LOB? But I thought the -R switch was supposed to tell it to look through all the subfolders.
Next I put a file named Test.LOB in the Hardscapes folder. The command above copies only that file and none of the subfolders. It looks like the -R switch is not doing its job. Do I have the syntax right?
Try this:
rsync -a --prune-empty-dirs --include '*/' --include '*.LOB' --exclude '*' /Users/Steve/Desktop/Hardscapes/ /Users/Steve/Desktop/Temp
As you already mentioned, directory Hardscapes itself contains no .LOB files. That's why your mask /Users/Steve/Desktop/Hardscapes/*.LOB results in matching no files at all.

CMD move files without knowing folder name

I'm using Windows CMD via an ANT Build file to move files from a sub-folder into a parent folder that is three levels up. The structure looks like this:
containingFolder
-tempFolder
-unkownNamedFolder
-contents.xyz
Using linux I can do this with the command mv */*.* .. with the current working directory being the temp folder. I don't know what the unknownNamedFolder will be called, but I do know that it will always be the only folder within the temp folder and that whatever content is within it needs to be extracted out to the containingFolder so that temp can be deleted and only the files will remain.
I've tried a command such as /c move *\*.* .. 2>NUL but this doesn't work.

Is there a way to copy files with a batch file to the folder that batch file is in?

So I am trying to make a batch file to sync an external hard drive.
My hard drive is not always connected to the same letter, so i cannot just make a batch file with xcopy F:\Folder1 G:\backupharddrive because G:\backupharddrivewould be variable
Is there a way to just copy to the folder the batch file is in?
Just use relative addressing, where . represents the current directory.
xcopy F:\Folder1 .
For future reference, you can also access the parent of the current folder (IOW, 1 level higher up in the directory tree) using ... This makes it handy to move up a level, or even over one. For instance, to copy files from C:\Temp\One to C:\Temp\Two, you can use
xcopy *.* ..\Two\
which means copy the files from this folder up one level and then over to the Two folder.
If you use dir from a command prompt, you'll see that in any level below the drive root you'll have items for . and .. in the list. (The root only has ., because it has no parent folder.

ApplScript to compress folder?

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.

Resources