Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Move multiple files to different directory using a single command

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 05-22-2018
Move multiple files to different directory using a single command

I have multiple files test1, test2, test3 etc. I want to move to a different directory with ABC_ prefixed to every file and and current dat time as postfix using a single command. (I will be using this is sftp with ! (command for local server).

I have tried the following but it gives error

Code:
cp * /other_dir/ABC_{*}_`date +%m%d%y`

# 2  
Old 05-22-2018
With a classic for loop:
Code:
for f in *; do cp "$f" /other_dir/ABC_"$f"_`date +%m%d%y`; done

The Following User Says Thank You to MadeInGermany For This Useful Post:
Soham (05-22-2018)
# 3  
Old 05-22-2018
Thanks. In fact I wanted a single command, but this will work for me
# 4  
Old 05-23-2018
I think only mmv can do it with one command.
Code:
mmv -c "*" /other_dir/ABC_"#1"_`date +%m%d%y`

# 5  
Old 05-23-2018
Is the rename (perl?) utility available at your target host?
# 6  
Old 05-23-2018
RudiC,

perl is available. Not rename UNIX command.
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to move gz files from one source directory to destination directory? venkat918 UNIX for Dummies Questions & Answers 11 04-06-2016 04:29 AM
List files with date, create directory, move to the created directory charli1 Shell Programming and Scripting 6 01-26-2016 02:00 PM
Sftp multiple files in single command sid2013 UNIX for Dummies Questions & Answers 3 12-18-2013 08:04 AM
Single command to create multiple empty files(no trailing lines as well). Onkar Banerjee Shell Programming and Scripting 4 09-05-2013 05:28 AM
Change to directory and search some file in that directory in single command saurau Shell Programming and Scripting 2 01-21-2013 07:53 AM
Empty out multiple files with a single command? Validatorian Shell Programming and Scripting 4 01-16-2012 04:08 PM
Grep multiple strings in multiple files using single command gagan4599 UNIX for Dummies Questions & Answers 2 01-19-2011 06:22 AM
Move all files in a directory tree to a signal directory? briandanielz UNIX for Dummies Questions & Answers 2 06-15-2008 05:20 PM
how to rename multiple files with a single command tayyabq8 Shell Programming and Scripting 5 03-18-2008 04:04 PM


All times are GMT -4. The time now is 02:14 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password