Questions tagged [mv]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
45 views

Command to move directories not starting with a `.`

I would like to move all subdirectories in a directory not starting with . in bash. For example, given this directory structure: subdir1/ subdir2/ .idea/ .venv/ The command should only move subdir1/ ...
melvio's user avatar
  • 121
0 votes
1 answer
65 views

How can I recover moved jpg files

On my ubuntu system I ran a command and moved all my jpg files to a single file by mistake src_dir=$1 echo "src_dir: $src_dir" for f in $src_dir/*; do if [ -f $f ]; then new_dir=...
Daemon's user avatar
  • 103
0 votes
3 answers
85 views

Rename multiple files in directory - Using sed or rename command

I have tried so many different sed, mv and rename commands - still I cannot rename these files. There are 50 plus files - I tried commands I found - Help thx Original filenames: PAGES_TEST1_SART1.XML ...
mattandbeyond's user avatar
0 votes
1 answer
46 views

Used mv instead of rename; files gone

While trying to batch rename a bunch of directories with rename 's/foo/barr/g' * I carelessly got mv in there instead of rename (mv 's/foo/bar/g' *), which seems to have cleared out the directory. But,...
devnulljp's user avatar
-1 votes
2 answers
61 views

How to escape left double quotes and right double quotes?

I want to change name with mv command. The file is inside left and right double quotes. e.g “My file name.” want to change it to My_file_name How can can I can escape the special character “ and ”. I ...
llesh's user avatar
  • 13
0 votes
3 answers
93 views

How do I change the extension of a long filename quickly?

original file: a really really long name with spaces.ext target file: the same name.new-ext command: mv *part of the name that'll give a unique answer.ext $(echo $(ls -l | grep -i *.ext | cut -d ' ' -...
kesarling He-Him's user avatar
1 vote
1 answer
35 views

How to use unix `mv` to rename files with unicode spaces(not U+20)?

$ ls cn* cn blah blah.txt $ ls cn\ * ls: cannot access 'cn *': No such file or directory $ ls cn*|hexdump -C 00000000 63 6e e2 80 85 62 6c 61 68 c2 a0 62 6c 61 68 2e |cn...blah..blah.| 00000010 74 ...
Remi Arntzen's user avatar
0 votes
1 answer
44 views

Find specific files in sufolders, and move them into a specific folder, batch

I am quite new at using Linux and the terminal and I am stuck with something. I have about 50 parent folders, all containing subfolders. One subfolder is called filtered_feature_bc_matrix. In an other ...
Camille Cohen's user avatar
0 votes
1 answer
97 views

shell one-liners for bulk-renaming multiple files

I am looking for two renaming one-liners to manage my music library. First concerns filenames. I would like to use as simple as possible names, that is : %track %title.ext for instance 01 Song name....
sylvainsab's user avatar
0 votes
1 answer
34 views

OSX13; how to mv series of x numbers of file chunks simultaneously to the series of directories

I have a following list of files; 260704 96 -rw-r--r-- 1 MacStudio staff 47131 Jul 28 20:18 ./GSM7673474_30_CC0022.barcodes.tsv.gz 260705 6264 -rw-r--r-- 1 MacStudio ...
akh22's user avatar
  • 115
0 votes
3 answers
83 views

simple question regarding moving files and folders

I am a noob, gains are slow. working on moving things around, playing. Command: mv man-pages(man-pages folder) /bob. instead of moving the man-pages folder(directory?) to directory bob, it took all 10 ...
bryce colwell's user avatar
0 votes
1 answer
78 views

Need help with a script that mv (renames) filenames that require single quotes in ls output or file operations

I need help with a script that mv (renames) filenames that are shown with single quotes in ls output or files that require single quotes for file operations. The script will be used to rename all ...
Psilospiral's user avatar
0 votes
1 answer
78 views

Delay when using `mv` command

I have a directory with many files. If I move a file to a subdirectory by mv myfile.* ./subdirectory/, I have a delay of about 3 seconds. Then the files are moved. How can I avoid this delay? The ...
Andy A.'s user avatar
  • 207
5 votes
3 answers
1k views

mv a bunch of files, but ask for each file

I would like to move a bunch of files on Linux like mv *.jpg /tmp/ But I would like to be asked for every single file, like mv --ask-me *.jpg /tmp/ do you want to move a.jpg? y/n y do you want to ...
Galdor's user avatar
  • 151
0 votes
0 answers
190 views

I accidentally moved a temp .zprofile to my actual .zprofile's file

My OS is MacOS Catalina. I was using a temporary .zprofile so I moved it to .zprofileold then moved .zprofilereactor to .zprofile but when switching back I accidentally moved .zprofile to .zprofileold ...
The_AH's user avatar
  • 11
2 votes
2 answers
525 views

Moving files without duplicating them to an S3FS-mounted storage bucket

Does the mv command (temporary) duplicate the moved files when the target is an S3FS mount? I have a VM that is reaching total space consumption. So, I'd like to move some files to a storage bucket (...
Sig's user avatar
  • 133
1 vote
2 answers
45 views

Move and rename multiple subdirectories to new location

My directories are setup in this way: dir 1 001 11-20-2001-RT SIMULATION-57976 002 11-20-2001-RT SIMULATION-30560 003 08-24-1998-RT SIMULATION-72882 and so on for about 250 entries. My goal is ...
goldenburrito's user avatar
0 votes
1 answer
261 views

Accidentally overwrote /usr/lib/x86_64-linux-gnu(using mv command) with file

While trying to move a file into /usr/lib/x86_64-linux-gnu, I accidentally overwrote x86_64-linux-gnu itself. The system(ArchLinux) is still running, but I'm not sure how to safely recover x86_64-...
Shringe_'s user avatar
0 votes
2 answers
71 views

The loop for file renaming doesn't work right

There are 32 *.dds files in a folder: pic-0.dds, pic-1.dds, pic-2.dds,...,pic-31.dds I'd like to rename them to be: 015040.dds, 015041.dds, 015042.dds,...,0150471.dds. I'm trying to use the ...
misha.physics's user avatar
0 votes
1 answer
95 views

mv: cannot stat '*.dds': No such file or directory

I'm using two short bash scripts for renaming all *.dds files in all directories. The first one: #!/bin/bash j=39; for i in *.dds; do let j+=1; mv $i 0150$j.dds; done The second one: CURDIR=`pwd` for ...
misha.physics's user avatar
0 votes
0 answers
73 views

How to simulate mv failing in a non-privileged Docker container?

An application inside a non-privileged Docker container executes mv <source_file> <dest_dir> under root, where <source_file> must be an existing regular file and <dest_dir> ...
Martin Heralecký's user avatar
0 votes
0 answers
76 views

/bin/mv: cannot stat ‘/opt/cisco-amp/download?product=LinuxProduct’: No such file or directory

/bin/mv: cannot stat ‘/opt/cisco-amp/download?product=LinuxProduct’: No such file or directory, I am getting this error while call this cmd in my shell script "/bin/mv "/opt/cisco-amp/...
Veeramani Muruganantham's user avatar
0 votes
1 answer
77 views

Possibly lost a file after trying to rename it

I had just created a script called myscript, and did a chmod +x myscript so it would execute. I tried to execute myscript and realized I forgot the .sh extension. So issued the following command in my ...
TexasTim's user avatar
0 votes
0 answers
70 views

mv file . deleted my file?

I tried moving a file to my local directory with a very simple mv /path/to/my/file . ... and now the file is just... gone? Not in the old directory, not in my current directory, simply not there. ...
Kilbo's user avatar
  • 101
7 votes
1 answer
2k views

mv: rename <oldname> to <newname>/<oldname>: Invalid argument

On my TrueNAS (FreeBSD 13.1) server I have a directory named OldHDD which I want to rename, but I get an error: % mv OldHDD oldhdd mv: rename OldHDD to oldhdd/OldHDD: Invalid argument I have tried ...
J.Lewandowski's user avatar
0 votes
1 answer
26 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 ...
Digit's user avatar
  • 391
0 votes
1 answer
143 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 ...
Root Loop's user avatar
  • 103
0 votes
1 answer
120 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 ...
matt's user avatar
  • 1
0 votes
1 answer
340 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 ...
graphics.guy's user avatar
0 votes
1 answer
50 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%...
anisphia's user avatar
1 vote
1 answer
75 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 ...
Vinod Kumar's user avatar
0 votes
1 answer
100 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 ...
Luca's user avatar
  • 1
0 votes
0 answers
48 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 │ ...
Bogdan Nicolae Stoian's user avatar
1 vote
1 answer
145 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 ...
Michael Altfield's user avatar
1 vote
5 answers
561 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 ...
Emil11's user avatar
  • 11
1 vote
1 answer
326 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/...
Harith's user avatar
  • 111
0 votes
0 answers
342 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 ...
user avatar
0 votes
0 answers
89 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, ...
xeruf's user avatar
  • 551
0 votes
1 answer
284 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 ...
LukeSmith's user avatar
0 votes
2 answers
1k 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/...
aaa's user avatar
  • 157
0 votes
1 answer
214 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 ...
aaa's user avatar
  • 157
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 ...
Connor Allsopp's user avatar
0 votes
2 answers
73 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 ...
mattia.b89's user avatar
  • 3,258
0 votes
1 answer
168 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_ ...
Mokan Velan's user avatar
3 votes
1 answer
1k 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-...
Nick_Z0's user avatar
  • 45
1 vote
1 answer
350 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 ./...
pascalbrax's user avatar
2 votes
2 answers
133 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 ...
mariano-daniel's user avatar
0 votes
0 answers
26 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 ...
palmasd1's user avatar
  • 115
1 vote
1 answer
63 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 ...
lessharm's user avatar
2 votes
0 answers
152 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 ...
smheidrich's user avatar

1
2 3 4 5
13