mv is a Unix command that moves a file to a target location.

learn more… | top users | synonyms

0
votes
1answer
23 views

Do recursive commands like mv cache a file list?

I want to move the directory content of the folder foo at a specific moment including the subfolder structure to another directory. If files are added to the origin folder they should not be moved. ...
0
votes
3answers
42 views

any way to mv a file without touch symbolic links

My motivation to ask this question is the following, one purpose of creating a symbolic link is to save space, but a simple mv command to move a directory elsewhere moves everything to the target ...
0
votes
1answer
63 views

mv not working in script, but works fine on the commandline [on hold]

I am trying to put together a simple script that renames a few files and directories. If I type the entries directly on the commandline they work fine. But as soon as I put them in a script it doesnt ...
-1
votes
1answer
29 views

move files from multiple source to multiple destination in one command

I am running ssh command and doing move command in it. ssh $USER_ID@$DESTINATION_SERVER "mv /source /destination" This is working fine. But I have to do this with multiple files in many source and ...
0
votes
1answer
33 views

Dispatching files to directories using name pattern matching

Consider: $ ls about-bar about-bar.pdf about-foo about-fou.pdf $ for f in *about-*.pdf; do mv "$f" "$(echo $f | sed -E 's:(about-.*).pdf:\1:')";done $ find . . ./about-bar ./about-bar/about-bar....
0
votes
1answer
27 views

Move files only if filename based regex does not match file in target dir

Best explained by an example: Source dir: file-a-1.txt file-b-1.txt Target dir: file-a-2.txt Expected result: file-a-2.txt file-b-1.txt Move all files from src dir to target dir only if ...
0
votes
2answers
87 views

mv .. with path: Where does my file go?

I have been using *nix systems for a while now, and I was surprised to see this situation in which mv misplaces or deletes my file. For example, I had a file foo.txt in the directory called ...
4
votes
3answers
82 views

Shell script to separate and move landscape and portrait images

I have a directory of jpg images. Is there a shell script (bash or zsh would be acceptable) that would move all landscape images into a directory, and all portrait images into another directory?
1
vote
1answer
38 views

What does '-t' do in mv command? Example below

ls -lrt |grep 'Jun 30th' | awk '{print $9}' | xargs mv -t /destinationFolder I'm trying to move files from certain date or pattern or createuser. It doesn't work properly without the -t option. ...
3
votes
1answer
44 views

Move files in nested directories to dest folder but keep basename and discard folder structure?

find $(MY_DIR)/source -type f -name "*.wav3" -print0 | \ xargs -0 -P $(NPROC) -n1 -I {} \ mv {} $(MY_DIR)/sound/{}.wav From the above I'm trying to find all .wav3 files, move them to the sound ...
0
votes
1answer
19 views

Create directory from files and move files

I want to move files based on a specific pattern. I was working with this code, but it does not work well with the task. for file in *.fastq.gz do dir="${file%R*}" mkdir -- "$dir" mv -- "$file" "$...
0
votes
1answer
46 views

I accidentally copied part of /* to /some/directory, how should I fix my mistake?

I did something stupid on a remote linux server: my working directory was /some/directory I ran for dir in $(ls | grep "a_pattern"); do mv $d/* ./my_subdirectory; done Now /some/directory/...
2
votes
1answer
46 views

Merely moving a directory inside another using mv

I just came across this weirdness: I want to do the equivalent of dragging a directory inside another (moving it). Trival day-to-day task for a GUI. here is my tree: . ├── assemble.py ├── Basic ...
3
votes
1answer
41 views

Recursive move (`mv -rn`, like `cp -rn`), a move that will only move not present files

Context I have user uploaded content that needs to be backed up. The content is over 3 separate servers at /var/www/domain/media/ (on each server it is in the same place). The backup is a NFS ...
2
votes
5answers
78 views

Move directory (with contents) to another user's home directory (without sudo)?

I have a directory that I want to move (with its contents, recursively) to another's user home directory. I don't have permissions to write to that user's home directory, but I know his password. I ...
3
votes
3answers
70 views

How can you move or copy specific files from a list of text files

So I have a directory of like 200 of the the following types of files: gre_6_c1_d34567.h3 gre_6_c1_d95543.h3 gre_6_c1_d42354.h3 gre_6_c1_d01452.h3 gre_6_c1_d23168.h3 gre_6_c1_435435.h3 The only ...
2
votes
1answer
113 views

Cannot mv to a subdirectory of itself

I am running this simple script and I am trying to create a cron job so that the file gets copied to my thumbdrive (with the new name) sudo cp /home/pi/NewLog.log /media/usb sleep 20 cd /media/...
1
vote
1answer
33 views

mv command with path wildcard containing random string

Im trying to move a file to a path which has a random string that I cannot know in advance ~/.config/foldername/45fhiu84.dev-edition/subfolder/ I have tried mv ~/Downloads/myfile.txt ~/.config/...
1
vote
2answers
42 views

how to move set of files in one-liner [duplicate]

I wanted to move 1000 files in a directory to another dir. I can do it if I'm in the original dir but if I try this mv $(ls /home/jeremy/source|tail -1000) /home/jeremy/dest from elsewhere, the ...
1
vote
1answer
55 views

cp vs. mv: which operation is more efficient?

I find myself moving reasonably large amount of data (20+ GB) from one directory tree to other. Often times they are on the same filesystem but sometimes they are on different ones. I do cp just to ...
0
votes
1answer
35 views

Adding prefix to the largest numbers filename

So I have a list of files that have numbers similar to the example below: /list/CAP_0045.dat /list/CAP_0044.dat /list/CAP_0046.dat I want to rename the file with the largest number to add a prefix ...
0
votes
1answer
54 views

Lost file when renaming it

I wrote a shell script to rename a whole bunch of files. Unfortunately, I accidentally saved it with Windows EOL so it messed up the file names with control-m characters at the end of each file. I ...
0
votes
1answer
25 views

Broken files after moving them back and forth [closed]

I have different partitions for / and ~, both with ext4 filesystems. In ~, I have a folder with many files, I tried to move the complete folder to the root partition mv ~/folder /folder/ In the ...
1
vote
0answers
22 views

How to remove a single quote from a file name? [duplicate]

I have some podcasts on my radio server which contain a timestamp when they should be played. I noticed one of them is put into single quotes 'filename.mp3', and I'm unable to remove them. Check this: ...
0
votes
1answer
47 views

mv misbehaves in shell script [closed]

I have the following folder structure: /backup /backup/copy.sh /backup/archive/ /backup/20160405_logs/ /backup/20160405_logs/sql.log /backup/20160405_logs/bak.log I want to move the folder ...
1
vote
2answers
44 views

Copy/move group files with renaming

I want to copy (or move) some files like cp ./patt*.py /other/path. However /other/path/ already contents files with the same names. So, I would like copy with renaming (adding some suffix, for ...
0
votes
1answer
16 views

Moved .mov to wrong directory and now it is a Unix Executable File [duplicate]

Was moving a movie file using mv but I typed the directory wrong. It turned my movie file into a Unix Executable File. mv /path/to/folder/1/this.mov /path/to/folder2 /folder2 did not exist Can I ...
4
votes
4answers
583 views

Why can't mv deal with existence of same-name directory in destination?

mv can't move a directory to a destination with a same-name directory: $ mv fortran/ imperative_PLs/ mv: cannot move ‘fortran/’ to ‘imperative_PLs/fortran’: Directory not empty Why does mv not ...
1
vote
1answer
59 views

Move specific directories from certain depth

I've tried to make a bash script that will help me move specific subfolders from my folder. The issue is,in the main folder photos I have folders named like this: 1,2,3,4,5,6,7,8,9,0 and inside them ...
-4
votes
1answer
46 views

how to move all files under one directory to home directory

I have the script files script1.ksh ...script10.ksh in the directory star2 PATH : home/aaa/star2 I need to move all the files under star2 to the home directory (home/aaa) NOTE : I do not want the ...
-2
votes
3answers
114 views

Move files based on filename into directory Year/Month/Day

I have files in the format YYYY_MM_DD_HH:MM:SS.swf that dump into a folder /home/user/dump/ I want to move these files into a new directory tree /home/user/save/year/month/day/ based on the ...
2
votes
2answers
62 views

How to recover multiple files which has been moved into one?

I was trying to rename (mv) few of my files and ran a wrong loop resulting into renaming all the 10 files into one. Now I can see only one file whereas there should have been ten files. How do I ...
0
votes
1answer
28 views

File -> ../../archive/folder/file restore

Hi i'm new to Linux and I need to use it temporary to set up LetsEncrypt. Once complete, I needed to move the /etc/letsencrypt/live/fullchain.pem file into the root dir but i moved the file incorectly:...
1
vote
4answers
51 views

Rename files randomly but without repetition

Suppose i have a folder with a lot of file names some very strange and nonsense I want to rename it like File-1 File-2 File-3 .. I have tried this(echo is for tryng) for name in *; do echo mv $...
5
votes
5answers
484 views

Rename folder with odd characters

I have a folder on my Mac called "␀␀␀␀HFS+ Private Data". I'm trying to delete it but it contains a bunch of odd characters that are choking unlink, rm and mv, making it difficult to remove it and ...
7
votes
7answers
573 views

How to rename splitfile[a-z] to splitfile[1-26]

I am trying to rename files named in the form of splitfile[a-z] to splitfile[1-26].csv, that is I want to rename splitfilea to splitfile1.csv and so on. I tried the following command: mv splitfile[...
0
votes
0answers
33 views

What is the effect of rsync with -E and --chmod?

Reading through a script I came across an rsync command with the following flags: -rtlDE -c --delete-after --chmod=u+rwX,go-rwx /path/to/dir1/ /path/to/dir2/ Background: I am refactoring the ...
0
votes
2answers
133 views

mv: No such file or directory error even though directory most certainly exists

I am attempting to do the very simple task of moving file.gz from /home/username/Downloads/file.gz into /mnt/gentoo/proc/ When I issue mv /home/username/Downloads/file.gz /mnt/gentoo/proc/ it returns ...
2
votes
2answers
67 views

How to definitely move a file without overwritting anything

Is there a command or option that will allow me to move files without overwriting anything? For the sake of argument, let us call the file foo.rar. Now the -n sort of works, it won't overwrite the ...
13
votes
5answers
2k views

mv: Move file only if destination does not exist

Can I use mv file1 file2 in a way that it only moves file1 to file2 if file2 doesn't exist? I've tried yes n | mv -i file1 file2 (this lets mv ask if file2 should be overridden and automatically ...
2
votes
1answer
76 views

What happens when multiple processes try to mv the same files between two different filesystems

I accidentally launched 32 processes (one process per core on my virtual machine) to mv some files between two ext4 filesystems, but only some of them were successfully mv'd: for i in `seq 1 32`; do ...
1
vote
5answers
226 views

List (or move) only files with a certain number of lines?

Dealing with a whole bunch of two-line config files, I'd like a way to exclude any files that have a different number of lines. So, something like: mv * destdir only if file contains exactly two ...
0
votes
2answers
184 views

File Transfer from Unix to Windows network shared location

How can I move the files from unix path to windows network shared path and the file should be moved to respective folder in shared path and if not then it is to create a folder based on file name and ...
0
votes
0answers
37 views

Error: rm /u01/sbldev01/siebel/siebsrvr/objects/esn/siebel_sia_OLD_20151110.txt: no such file or directory

I have a small sh that rename 2 files. However, when I try to download the file generated, I got the error: Error: /u01/sbldev01/siebel/siebsrvr/objects/esn/siebel_sia_OLD_20151110.txt: open ...
2
votes
4answers
88 views

Move files/table following selection criteria

Considering a variable a describing temperature series for the city a. I have 9 directories (a1, a2, a3, a4, a5, a6, a7, a8, a9) each of them containing a table (respectively a1.txt, a2.txt, a3.txt, ...
3
votes
4answers
109 views

Moving a list of files by matching them to a destination index

Say I have two text files src.txt and dest.txt, where src.txt contains a list of filenames (some of which include spaces) in /src/dir/ and dest.txt contains, in random order, a list of the complete ...
3
votes
3answers
606 views

How do I pipe the output of tar through mv?

A previous question of mine asked how to pipe downloaded files through tar, now I would like to know how to pipe the output of tar through mv. See I have this command at the moment: wget -c https://...
2
votes
1answer
157 views

Bash script unable to move files

I'm trying to write a "janitor" script that will run as a cron job in one specific directory. It is supposed to create an archive folder with the date of creation in the name, and then find and move ...
1
vote
3answers
159 views

Move files up by a directory by depth criteria

I have a directory tree that looks like this (simplified, in truth there are hundreds of folders): . ├── a │   └── b │   └── a.h5 ├── b │   ├── b │   │   └── e.h5 │   └── c │   ├── a.h5 │   ...
1
vote
3answers
40 views

Moving certain files to new location (and appending the datettime)

I have two Directories: /routea/path/to/dir1 /routeb/path/to/dir2 in dir1 I have some files: file.name file.name.1 file.name.2 file.name.3 (There may be more than the 4 files). I need to move ...