Questions tagged [mv]
mv is a Unix command that moves a file to a target location.
621
questions
0
votes
1
answer
17
views
How can numbered files be moved and renamed to subsequent numbered files to correct directory?
In ~/wrongdir there are mpv-shot0001.jpg, mpv-shot0002.jpg, mpv-shot0003.jpg, mpv-shot0004.jpg, mpv-shot0005.jpg
where the screenshot key was pressed when a mpv was initiated in ~/wrongdir.
The ...
0
votes
1
answer
37
views
What exactly happens in the OneFS (FreeBSD) files system if I move files from one directory to another?
If I do an mv command from the command line in OneFS (Isilon, FreeBSD based), what exactly happens in the background and on the disks?
Will the data be physically moved from sectors to other sectors ...
0
votes
1
answer
21
views
Move all the file present in a directory with same letter/word in them to another directory
rda@MacBook-Pro X.WORK % ls
Assignment1.file Sec3 moremumbo.woot
FICTION.bak Test-1.bak mumble.txt
File-1.bat Test-1.txt mumbo.file
FundaOfIT.txt Text-1.xtxt ...
0
votes
0
answers
24
views
Delete parent folder while keeping contents
I have a structure that is as follow:
parentdir/nesteddir/content/files
within parentdir are hundreds of subdirectories with differnet names (I am just using an example of 'nesteddir'
I will cd into ...
0
votes
1
answer
42
views
Help with -maxdepth in 'find -exec mv' command line
I'm working on a sorting/filtering cron script to process incoming files based on a set of constant strings (logfile, history, dataset, etc). The files to be sorted all sit under a common folder, some ...
0
votes
1
answer
43
views
Moves files with the same name to a directory and writes the counted number to the directory name
find /volume1/file/* -type f \( -name "*DF*" -a -name "*LIVE*" \) -print0 | while IFS= read -d '' file
do
# extract the name of the directory to create
dirName="${file%...
1
vote
1
answer
35
views
Moving files to a new directory with a condition
I have 100s of files in a directory, and I want to keep only those where a part of first file matches with another file and if condition is not fulfilled than mv all files without its corresponding ...
0
votes
1
answer
70
views
why did I loose all files with mv command?
I wanted to move one level up the entire content of a directory (with all subfolders)
cd /dir/subdir
mv * /dir
cd ..
rm -R subir/
In /dir I have all folders and subfolders but they are empty. What ...
0
votes
0
answers
43
views
Move directory contents up one level only if it contains files
How to I move directory contects up one level only if it contains files. Some hints would help. Thanks!
Example to move up one level:
├── AAA
│ └── AAA1
│ ├── 001.jpg
│ ├── 002.jpg
│ ...
1
vote
1
answer
42
views
How to "move" a file currently being written-to by a process (bash, copy, truncate)
What's the best way to automatically rotate a file in BASH to prevent the possibility of data loss if that file is sporadically being written-to?
For example, I want to do this, but I think it's ...
1
vote
5
answers
129
views
Move all PDF files to a separate directory that doesn't exist beforehand
I am writing a simple method to mass move files and have attempted two approaches:
#(1)
find . -name '*.pdf' | xargs -I{} mkdir pdfs; mv {} pdfs
#(2)
find . -name '*.pdf' -exec mv {} pdfs \+
The ...
1
vote
1
answer
121
views
Moving a file from ROOT directory resulted in loss of data
Before moving, I checked the directory and it had all the contents in it.
Then I moved it to a directory in my C drive (I'm using WSL) with this command:
sudo mv c_dir/ mnt/c/Users/L570/Documents/...
0
votes
0
answers
76
views
Moving a file to a directory with spaces in the name [duplicate]
The destination directory is a directory with spaces in the name: /opt/config/Sn Lk
Now I wrote a script which moves a file from my directory to this directory, but the move fails
Although the echo of ...
0
votes
0
answers
51
views
mv and cp with automatic diff
Is there a program out there like mv and cp, which upon conflict automatically shows a diff before asking whether to override the target file?
This is such a basic feature in graphical file managers,
...
0
votes
1
answer
27
views
Moving folder contents up 2 directory levels
I'm trying to write a command that uses mv to move files two directory levels up.
So if the folder order goes like this: ~/Test/2020-08-01/001/002/file.txt, I want to move file.txt from directory 002 ...
0
votes
2
answers
74
views
move and make directory
I know its a big classical but I didn't found the exact situation that concerns me
I need a mkdir+mv command that can be invoked like that :
mvdir /home/user/Documents/irs.pdf /mnt/work/45/223/insight/...
0
votes
1
answer
62
views
mv file order file mv
How to choose in which order mv treat files? (I mean, I can invoke it manually, but the work of preserving paths and work recursively can become rapidly a problem)
I have an fs mounted on /mnt and ...
0
votes
0
answers
25
views
mv file.sh /location where the file.sh gone? [duplicate]
So in my archlinux set up, when I was tired I accidentally typed...
mv file.sh /location
instead of...
mv file.sh location/
So I was wondering where that file has gone? and can I get it back?
I have ...
0
votes
2
answers
45
views
mv command: how to short directory location [duplicate]
I need to rename a file in a multi-nested directory, that's very long location; I'll use mv command.
I'd like to save time by typing only once the full location.
Is there a way to shorten the ...
0
votes
1
answer
19
views
Error while changing name "mv: target ‘DGProdAtt_1_20221101101807.xlsx’ is not a directory"
Hi I am trying to change a file name but it is giving me error as below :
Original filename:005356209MAINSFTP_005356209DSM_ DGProdAtt_1_2022_11_01_10_18_07.xlsx
mv 005356209MAINSFTP_005356209DSM_ ...
2
votes
1
answer
594
views
Move files to subfolders based on part of their filename
I have files with filenames such as:
text_2_2022-11-22_K03_10k_66_P578_B06_2999dl_text_693_coff_442.jpg
text_2_2022-11-22_K03_10k_66_P578_B06_2999dl_text_693_coff_432.jpg
text_2_2022-11-...
1
vote
1
answer
78
views
How to move a bunch of files in their own new folder
I have a list of files in a folder:
./file1.ext
./file2.ext2
./file3.ext
I want to move all these files in their own new folder with their related name, like:
./file1/file1.ext
./file2/file2.ext2
./...
2
votes
2
answers
90
views
change file extensions as with 'ren' command in DOS?
Shell: zsh
Hello folks, I am trying to quickly change the file extension of a file like in DOS.
I did find this question about it (sort of) it still does not answer the question:
Rename multiple files ...
0
votes
0
answers
17
views
Issue while moving existed file
I have a script, that does queries to clickhouse stats data that's further used for monitoring.
Every query output is stored to /tmp/file.out.tmp file, and at the end of script that file is renaming ...
1
vote
1
answer
54
views
Canceling Move Command From Drive A to B resulted in files disapearing
Question: Where did the files go?
I unintentionally typed the wrong path (/mnt/dc instead of /mnt/de) when moving a couple of large directories. My intention was to move the files to a new path on the ...
2
votes
0
answers
43
views
Does mv across filesystems flush the destination filesystem cache between copy and delete?
mv is implemented as a simple rename() whenever possible, falling back to copy-then-delete whenever renaming doesn't work. In practice (but not in theory), these two cases correspond to source and ...
0
votes
2
answers
86
views
How to rename numerically titled file names by 1 digit?
This feels so simple, and yet I'm entirely stumped. Needless to say I am absolutely new to this. I have a directory with files numerically numbered from 000 to 020. I would like to rename these files ...
3
votes
1
answer
798
views
mv: A and B are the same file
I'm trying to move 5 .MOV files to a folder called MOV. I'm using find to list the files and mv to move the files:
$ mkdir MOV ; find . -type f -iname '*.MOV' -exec mv "{}" "MOV" \;...
0
votes
1
answer
49
views
Create directory using filenames and move the files to its respective folder
My question is a bit different than:
Create directory using filenames and move the files to its repective folder
Since in the same folder I have two similar copy of each file like:
001.txt and 001(1)....
0
votes
2
answers
60
views
How can I modify multiple filenames?
I am having these files in a folder:
1658286488_2022_07_21_15.1.2-ee_gitlab_backup.tar
1658546417_2022_07_22_15.1.2-ee_gitlab_backup.tar
2258286417_2022_07_23_15.1.2-ee_gitlab_backup.tar
and I want ...
0
votes
0
answers
389
views
when `mv` command delete original directories or files
I am moving a large directory(contains many other directoris and files), after several minutes, I found that the original directory is not getting smaller, still the same size as begining.
Does mv ...
1
vote
1
answer
67
views
How to move a set of files and directories, excluding another (sub-)set
I have two bash arrays, one of them (named toMove) contains paths to files and directories to move (not copy) somewhere else, and the other one (named exclude) contains paths to files and directories ...
0
votes
1
answer
50
views
Can you reverse a bash script with a series of mv commands?
If I have a script rename_everything.sh which contains
mv 2022-05-03.txt hike_valley.txt
mv 2022-05-20.txt not_overcooked.txt
mv 2022-05-22.txt return_trip.txt
but am nervous to run that in the one ...
0
votes
2
answers
144
views
Why can't dot files in root directory be moved
There're some files, folders and dot files in a directory like following
|-folder1
|----folder2
|----file.json
|----file2.php
|----.env
|----.dockerfile
|----.someconfig
|----.dockerignore
I run ...
0
votes
1
answer
116
views
What happens when you name a folder as ".."?
Instead of moving a folder to parent directory, I renamed it as ".." using mv folder_name ... Do you have any solution to recover the folder or is it just deleted? (macos 12.4)
0
votes
0
answers
289
views
mv throw error when executed in shell script
OS: Ubuntu
I have the folder testfolder/subfolder with content
backup
file1.txt
file2.txt
testFolder
And I have script testfolder/testMv.sh
Now I'm inside of the bash session and do the following:
...
1
vote
2
answers
126
views
How to move file contents deeper without copying
I have files in /home/jjblack/foo/. I want to move all the contents of this directory into /home/jjblack/foo/bar/.
I am unable to copy the contents elsewhere as there is not enough disk space. I am ...
1
vote
1
answer
124
views
Avoid symlink race rcondition with "mv" in Bash
I want to safely write to a destination file (as root, unter common Linux'es) with "echo" (or catany other Bash built-in stuff) like this
echo "foo" > /destination/dir/filename
...
19
votes
1
answer
953
views
'find -exec mv' misses 4 files
I wanted to move about 1000 mp3 files from a directory called 'music' containing a complicated nested directory structure, to a single directory called 'mp3s', so that I could listen to them in my car....
0
votes
2
answers
72
views
Trying to rename bulk folders using standard tools
I am trying to bulk rename many folders but for some reason my approach does not seem to work. I am trying to use the following script but it does nothing. I am new to programming so any suggestions ...
1
vote
1
answer
397
views
Unzip a zip file whose content's name is too long in Ubuntu terminal
I have a zip file, sample.zip, which contains a PDF whose name is too long. I tried to unzip it in Ubuntu terminal through
unzip sample.zip
however, it shows an error that "File name too long&...
0
votes
0
answers
135
views
Why does alias to move into usr/local/bin fails [duplicate]
I am trying to have an alias to move binaries into a folder on my path.
Currently I have:
alias addapp='sudo mv $1 /usr/local/bin'
1
vote
1
answer
65
views
Using move command to move all files and subdirectories with find
I have a folder /home/storage/aggregate_data with many sub-folders which in turn contain many files and sub-folders.
I want to copy all the files older than 90 days within the folder /home/storage/...
1
vote
1
answer
217
views
Is there a more reliable cp and mv which verifies the file and / or folder transferred to be identical? (such as by rsync?)
Is there a way to use cp and / or mv so that it verifies the files to be identical. This is especially true for mv, which would remove the original file, so if the destination file is corrupted, then ...
0
votes
3
answers
96
views
How to display a prompt and prevent execution against basic but dangerous commands like mv or rm
Objective
Whenever I use mv (or commands of similar nature) I want my shell to prompt me something like "Hey, you used mv. Sorry but do it again using mv -i".
I'd like to know the reasonable ...
1
vote
2
answers
36
views
Working with graphics files and trying to rename sequentially with mv
I have been looking an older question answering a similar question, but apparently I am not too good at making the code work. I am on zsh not bash, but other bash shell scripts have worked fine, so I ...
1
vote
0
answers
132
views
move command unable to remove file
I'm trying to move a set of 60GB files from one folder to another using
mv -v /home/mnt1/Daily_IMSI_Report/* /mnt2/Archive_1/Daily_IMSI_Report/
But the command is not executing after copying only one ...
23
votes
3
answers
7k
views
I lost files by using the "mv" command and I don't know where they are!
I lost some files by using the mv command. I don't know where they are. They are not in the directory to which I intended to copy them.
Below is a transcript of what I did:
samuelcayo@CAYS07019906:~/...
0
votes
0
answers
15
views
rsync --remove-source-files vs mv [duplicate]
I am trying to move files from /var/run to /var/lib: mv /var/run/dir/child_dir /var/lib/dir. /var/lib/dir is empty. Since /var/run and /var/lib are in two different filesystems, mv copies all the ...
0
votes
0
answers
123
views
Does mv copy files when move files from /var/run to /var/lib?
I am trying to move files from /var/run to /var/lib: mv /var/run/dir/child_dir /var/lib/dir. /var/lib/dir is empty.
From When we use mv command, what changes take place in HDD? it seems that mv will ...