mv

How to emulate cp and mv --parent on osx

独自空忆成欢 提交于 2019-12-07 05:24:09
问题 Osx mv and cp does not have the --parents option, so how does one emulate it ? I.e. mv x/y/a.txt s/x/y/a.txt when s is empty gives a no directory found error unless one does a mkdir first which is rather cumbersome when trying to do this did thousands of files. 回答1: The solution (which works on all platforms that has an rsync) is: Use find or some other tool to create a file with the files you want moved/copied, i.e. find *.mp3 > files.txt Then use rsync files-from to specify it and by using

Moving Files and Folders Accidentally to Non-existent Places

本小妞迷上赌 提交于 2019-12-07 04:26:42
问题 I often do the command such as: mv folder $something_that_does_not_exist mv files* $something_that_does_not_exist Then, I realise that my files are gone. I cannot see them even in the folder "$something_that_does_not_exist". Where have my files and folders gone? How can I get them back? 回答1: In order to prevent this problem, I have a habit of always appending a / to the end of directory names when using cp or mv : $ touch foo $ mv foo bar/ mv: cannot move `foo' to `bar/foo': No such file or

Bash mv not a directory

主宰稳场 提交于 2019-12-06 08:46:56
I have part of my script that goes like this: while read line do code=`echo ${line} | awk '{print $1}'` awk -f ${supscript}/rearrange.sh < ${base}/${code} mv temp_output* "$code"temp_output* done < filelist The script is working; the only problem is that when it is trying to rename the file I got the following error message: mv: target `pollcodetemp_output*' is not a directory Maybe it is something related with the IFS. I try to specify this at the beginning of the script as: IFS=' ' But it is not working. I'm using a Windows text editor but I have already removed the CR. Most likely, you just

mv: invalid option — '0'

China☆狼群 提交于 2019-12-05 14:25:37
How can I rename files with "-" in front of the filename, for example: "-0001.jpg" Everyime I try to run: for i in *; do mv "$i" "${i//-/}"; done or: for i in *; do mv "$i" "${i#*-}"; done I got this error: mv: invalid option -- '0' Try `mv --help' for more information. Thanks for any light! mv ./-00008.jpg to/some/where.jpg ^ - start with path... as with most gnu commands, use the -- switch before the filename with the hyphen. it signifies "end of switches". Put a double - before the arguments that can contain "-" in the begin; then there can't be options after --. mv OPTIONS -- ... 来源: https

Moving Files and Folders Accidentally to Non-existent Places

一世执手 提交于 2019-12-05 10:37:25
I often do the command such as: mv folder $something_that_does_not_exist mv files* $something_that_does_not_exist Then, I realise that my files are gone. I cannot see them even in the folder "$something_that_does_not_exist". Where have my files and folders gone? How can I get them back? In order to prevent this problem, I have a habit of always appending a / to the end of directory names when using cp or mv : $ touch foo $ mv foo bar/ mv: cannot move `foo' to `bar/foo': No such file or directory Without the trailing slash, mv does a file rename operation. You may find that your file(s) have

How to use mv command to rename multiple files in unix?

假装没事ソ 提交于 2019-12-05 09:53:16
I am trying to rename multiple files with extension xyz[n] to extension xyz example : mv *.xyz[1] to *.xyz but the error is coming as - " *.xyz No such file or directory" Don't know if mv can directly work using * but this would work find ./ -name "*.xyz\[*\]" | while read line do mv "$line" ${line%.*}.xyz done Mikaël Mayer Let's say we have some files as shown below.Now i want remove the part -(ab...) from those files. > ls -1 foo* foo-bar-(ab-4529111094).txt foo-bar-foo-bar-(ab-189534).txt foo-bar-foo-bar-bar-(ab-24937932201).txt So the expected file names would be : > ls -1 foo* foo-bar-foo

bash error renaming files with spaces - mv target is not a directory

冷暖自知 提交于 2019-12-04 01:14:04
I'm trying to rename a bunch of files which contain spaces in them, getting rid of the spaces. I thought I found the correct bash command: for f in *.txt; do mv \"$f\" ${f/ /}; done However, this gives the error, "mv: target is not a directory" for each file. If I replace 'mv' with 'echo mv' in the command, it prints the proper mv command for each file, and if I type any of those mv commands individually, they work. For example, if I have 2 files, "a .txt", and "b .txt", and run the command above, I get: mv: target 'a.txt' is not a directory mv: target 'b.txt' is not a directory If I type the

Permissions required to move file to different directory in Unix/Linux [closed]

五迷三道 提交于 2019-12-03 16:16:55
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I would like clarification on the permissions required, in order to move a file A from directory B to directory C (the command would be "mv B/A C/A", I think), with name unchanged. Am I correct to think that the following are required? The user/group doing the move must have write permission for directory B (or

Remove a list of words from filename

独自空忆成欢 提交于 2019-12-03 15:19:14
I am trying to remove a list of specific words from all my files with a certain directory and replace them with nothing. So: This Awesome Content 720p BLAH FOO BANG OOO - 30.9.2013.mp4 Becomes: This Awesome Content - 30.9.2013.mp4 Now the following works great for a single find and replace one word. find path/to/folder/ -maxdepth 3 -name '*.*' -execdir bash -c 'mv -i "$1" "${1//foo/}"' bash {} \; I have also tried just multiple finds but this seems like a very long way of doing it and i seem to run into issues this way. Couple of issues i have: Want it to be case insensitive Need "${1//foo/}"

Find files, rename in place unix bash

空扰寡人 提交于 2019-12-03 12:44:53
问题 This should be relatively trivial but I have been trying for some time without much luck. I have a directory, with many sub-directories, each with their own structure and files. I am looking to find all .java files within any directory under the working directory, and rename them to a particular name. For example, I would like to name all of the java files test.java . If the directory structure is a follows: ./files/abc/src/abc.java ./files/eee/src/foo.java ./files/roo/src/jam.java I want to