move only specific folders and subfolders using mv - mv

I am trying to move specific folder and subfolders from a directory. In the below I am trying to move a folder BAM and its two subfolders and another folder Bedtools from the main directory to a destination but getting the errors below. Thank you :).
folder structure
8-21-2016 -- Top level is date
BAM -- parent directory
Coverage --child directory
Validation -- child directory
Bedtools -- parent directory
Test -- parent directory
ID -- parent directory
mv -u /home/cmccabe/Desktop/NGS/API/6-10-2016/bam/* bedtools/ /media/cmccabe/"My Book Western Digital"
mv: inter-device move failed: ‘/home/cmccabe/Desktop/NGS/API/6-10-2016/bam/coverage’ to ‘/media/cmccabe/My Book Western Digital/coverage’; unable to remove target: Is a directory
mv: cannot stat ‘bedtools/’: No such file or directory

Apparently bedtools does not exist in your local path. And about the other error message mv: inter-device move failed: ‘/home/cmccabe/Desktop/NGS/API/6-10-2016/bam/coverage’ to ‘/media/cmccabe/My Book Western Digital/coverage’; unable to remove target: Is a directory, probably that folder is not writable for your user. Move mv command will remove it from the device but probably you don't have the rights.
Check trying as root (with sudo) for the second problem. For the bedtools folder, please check your local path.

Related

does ROBOCOPY have any command options to create source folder if not exist

For example, if source folder is c:\abc\file1 which doesnot exist..it should create the folder in source rather than throwing this error
ERROR 2 (0x00000002) Accessing Source Directory cc:\abc\file1
The system cannot find the file specified.

moving files to different folders from 1

I have 200,000 files I want to send to different folders based on key words in the file name
in English if a file name has (shtf or prepper or prepping or survival) in the name send(move) it to folder shtf
if a file has (cookbook or gluten or recipe) move to food folder
*cookbook* *GLUTEN* *RECIPE*
example
(file name)
more shtf tips.epub move to folder shtf
ifshtfbeready.epub move to folder shtf
oldworldcookbook.epub move to folder food
i'm old retired ibmer small basic sas dos commands or ????
Here is a bash command, you may be able to adapt it into dos etc. I'm posting this because others may it useful as well.
find . | grep -E "(cookbook|gluten|recipe)" | while read name; do mv $name directory; done;
Where directory is the name of the directory you want to move the file. You can replace . with whatever starting directory you want, of course.
You can use wildcard in the source filename list and use a directory as the target to move multiple files with one command.
move c:\dir1\*cookbook*.* c:\food
move c:\dir1\*gluten*.* c:\food

Transfer folder using pscp (Putty) from Windows to Linux

Using puttys pscp -r folder\to\copy\* user#server:/path/to/copy/folder/to it only copies the content of path\to\copy\folder\* and does not include the "main" folder which the subfiles and subdirectories are in.
What I need is that the folder itself is also copied such that I get a folder with the same name as the one I copied with the content inside.
I know I just can create a parent-folder for the one I want to copy and parse that as the path\to\copy\folder\* but that is not the case
Just use pscp -r folder\to\copy user#server:/path/to/copy/folder/to.

Mv file problems when moving file back in path

I am completing Zed Shaw's Learn Python the Hard Way and am stuck on a concept in the appendix command line crash course in Windows PowerShell.
My problem is with the move (mv) command, specifically moving a file farther back in the path (hope that makes sense). Here is what I did:
I created a directory called temp, and within that directory created a .txt file called awesome.txt and another dirctory called newplace. Then, I write the command "mv awesome.txt newplace" and the awesome.txt file is moved to the directory newplace. Great!
The problem is that I want to move the file awesome.txt back to its original place in the directory temp. When I change my working directory to the directory newplace "cd newplace" and then type "mv awesome.txt temp" the file awesome.txt does not move back to the directory temp, but instead converts from a .txt file to a "file" and stays put in the newplace directory.
Folders like this are nested inside each other:
c:\temp
c:\temp\newplace\
When you cd around, you go into a folder (, e.g. cd temp:
c:\temp\ (o_o)
c:\temp\newplace\
And you can only see things in the same folder you are in. So you can move into newplace because that name makes sense where you are. But when you are in newplace
c:\temp\
c:\temp\newplace\ (o_o)
You can't move to temp because you don't know where it is. You don't have an index of every directory name on the entire computer that you can shortcut to, you only have two options: something in the same place you are, or something with an absolute path - a full name of where it is. c:\temp\.
So mv awesome.txt temp tries to put it inside temp where you are -> c:\temp\newplace\temp\ -> that doesn't exist, so it assumes you're moving it to a new name in the same place.
You would need mv awesome.txt c:\temp\ to specify it properly.
Except there's a sneaky shortcut, anywhere you are, there is automagically a path called .. which means the folder one <-- thatway from where I am.
So you could mv awesome.txt ..\ to push it back one level in the path, without needing to know exactly where that is. This is probably what Zed Shaw is expecting.

Winrar CommandLine & Powershell : Exclude Full Directory Path Structure

Suppose I have a directory structure like
C:\Users\Desktop\abc\d
I want to rar archive the abc folder so that the structure of rar is:
abc\d
When I try using powershell to archive, winrar replicates the full path inside the archive, like:
\Users\Desktop\abc\d
I dont want the full path to be created inside the archive
Here's the script:
https://gist.github.com/saurabhwahile/50f1091fb29c2bb327b7
What am I doing wrong?
Use the command line:
Rar.exe a -r -ep1 Test.rar "C:\Users\Desktop\abc"
Rar.exe is the console version of WinRAR stored in same directory as WinRAR.exe. You can use this command line also with WinRAR.exe if you want to see the compression process in a graphic window.
a is the command and means add files to archive.
-r is a switch to recursively add all files and subdirectories including empty subdirectories to the archive.
-ep1 is another switch which results in execluding base directory.
For this command line the base directory is "C:\Users\Desktop\" and therefore the created archive Test.rar contains only abc and all files and subdirectories in directory abc which is what you want.
One more hint: Using the command line
Rar.exe a -r -ep1 Test.rar "C:\Users\Desktop\abc\"
results in adding all files and subdirectories of directory abc to the archive, but without directory name abc being also stored in the archive. The backslash at end makes this difference.
In other words: On using switch -ep1 everything up to last backslash in file/directory specification is not added to the archive.
For more information about available switches see the text file Rar.txt in the program files directory of WinRAR.