Move multiple files with same name in same directory
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt
How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt
Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.
command-line files mv
bumped to the homepage by Community⦠2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |Â
up vote
0
down vote
favorite
I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt
How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt
Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.
command-line files mv
bumped to the homepage by Community⦠2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Thanks @icarus. Have updated the description with a detailed scenario.
â Dud
Nov 28 '16 at 2:44
Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
â icarus
Nov 28 '16 at 2:47
Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
â Dud
Nov 28 '16 at 2:52
1
Because you have a fixed filename, the FTP process will overwrite the previousinput.txt
, so you will only have a single file calledinput.txt
at a time (which will be the most recent one).
â icarus
Nov 28 '16 at 3:02
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt
How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt
Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.
command-line files mv
I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt
How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt
Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.
command-line files mv
command-line files mv
edited Nov 28 '16 at 2:43
asked Nov 28 '16 at 2:20
Dud
84
84
bumped to the homepage by Community⦠2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community⦠2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Thanks @icarus. Have updated the description with a detailed scenario.
â Dud
Nov 28 '16 at 2:44
Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
â icarus
Nov 28 '16 at 2:47
Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
â Dud
Nov 28 '16 at 2:52
1
Because you have a fixed filename, the FTP process will overwrite the previousinput.txt
, so you will only have a single file calledinput.txt
at a time (which will be the most recent one).
â icarus
Nov 28 '16 at 3:02
add a comment |Â
Thanks @icarus. Have updated the description with a detailed scenario.
â Dud
Nov 28 '16 at 2:44
Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
â icarus
Nov 28 '16 at 2:47
Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
â Dud
Nov 28 '16 at 2:52
1
Because you have a fixed filename, the FTP process will overwrite the previousinput.txt
, so you will only have a single file calledinput.txt
at a time (which will be the most recent one).
â icarus
Nov 28 '16 at 3:02
Thanks @icarus. Have updated the description with a detailed scenario.
â Dud
Nov 28 '16 at 2:44
Thanks @icarus. Have updated the description with a detailed scenario.
â Dud
Nov 28 '16 at 2:44
Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
â icarus
Nov 28 '16 at 2:47
Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
â icarus
Nov 28 '16 at 2:47
Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
â Dud
Nov 28 '16 at 2:52
Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
â Dud
Nov 28 '16 at 2:52
1
1
Because you have a fixed filename, the FTP process will overwrite the previous
input.txt
, so you will only have a single file called input.txt
at a time (which will be the most recent one).â icarus
Nov 28 '16 at 3:02
Because you have a fixed filename, the FTP process will overwrite the previous
input.txt
, so you will only have a single file called input.txt
at a time (which will be the most recent one).â icarus
Nov 28 '16 at 3:02
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
I have a directory with multiple files of same name.
Well, you shouldn't. How can you even cat
their contents? (that is, without getting only the first file of the same name each time).
How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt
I'd settle for trying to give them different names:
mv File.txt ../new/File.txt.1
mv File.txt ../new/File.txt.2
and see if you end up with distinct files that way.
Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.
This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
â Dud
Nov 28 '16 at 2:40
@Dudul Please update your question with more details of this process.
â DepressedDaniel
Nov 28 '16 at 2:41
Thanks Daniel. I hope this makes it clearer. Should had put in the description.
â Dud
Nov 28 '16 at 2:42
add a comment |Â
up vote
0
down vote
Can you not use a wildcard to move it all e.g.
mv file.tx* /new/
This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file
Hope that helps.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I have a directory with multiple files of same name.
Well, you shouldn't. How can you even cat
their contents? (that is, without getting only the first file of the same name each time).
How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt
I'd settle for trying to give them different names:
mv File.txt ../new/File.txt.1
mv File.txt ../new/File.txt.2
and see if you end up with distinct files that way.
Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.
This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
â Dud
Nov 28 '16 at 2:40
@Dudul Please update your question with more details of this process.
â DepressedDaniel
Nov 28 '16 at 2:41
Thanks Daniel. I hope this makes it clearer. Should had put in the description.
â Dud
Nov 28 '16 at 2:42
add a comment |Â
up vote
0
down vote
I have a directory with multiple files of same name.
Well, you shouldn't. How can you even cat
their contents? (that is, without getting only the first file of the same name each time).
How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt
I'd settle for trying to give them different names:
mv File.txt ../new/File.txt.1
mv File.txt ../new/File.txt.2
and see if you end up with distinct files that way.
Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.
This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
â Dud
Nov 28 '16 at 2:40
@Dudul Please update your question with more details of this process.
â DepressedDaniel
Nov 28 '16 at 2:41
Thanks Daniel. I hope this makes it clearer. Should had put in the description.
â Dud
Nov 28 '16 at 2:42
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I have a directory with multiple files of same name.
Well, you shouldn't. How can you even cat
their contents? (that is, without getting only the first file of the same name each time).
How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt
I'd settle for trying to give them different names:
mv File.txt ../new/File.txt.1
mv File.txt ../new/File.txt.2
and see if you end up with distinct files that way.
Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.
This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.
I have a directory with multiple files of same name.
Well, you shouldn't. How can you even cat
their contents? (that is, without getting only the first file of the same name each time).
How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt
I'd settle for trying to give them different names:
mv File.txt ../new/File.txt.1
mv File.txt ../new/File.txt.2
and see if you end up with distinct files that way.
Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.
This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.
edited Nov 28 '16 at 2:47
answered Nov 28 '16 at 2:36
DepressedDaniel
3,355413
3,355413
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
â Dud
Nov 28 '16 at 2:40
@Dudul Please update your question with more details of this process.
â DepressedDaniel
Nov 28 '16 at 2:41
Thanks Daniel. I hope this makes it clearer. Should had put in the description.
â Dud
Nov 28 '16 at 2:42
add a comment |Â
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
â Dud
Nov 28 '16 at 2:40
@Dudul Please update your question with more details of this process.
â DepressedDaniel
Nov 28 '16 at 2:41
Thanks Daniel. I hope this makes it clearer. Should had put in the description.
â Dud
Nov 28 '16 at 2:42
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
â Dud
Nov 28 '16 at 2:40
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
â Dud
Nov 28 '16 at 2:40
@Dudul Please update your question with more details of this process.
â DepressedDaniel
Nov 28 '16 at 2:41
@Dudul Please update your question with more details of this process.
â DepressedDaniel
Nov 28 '16 at 2:41
Thanks Daniel. I hope this makes it clearer. Should had put in the description.
â Dud
Nov 28 '16 at 2:42
Thanks Daniel. I hope this makes it clearer. Should had put in the description.
â Dud
Nov 28 '16 at 2:42
add a comment |Â
up vote
0
down vote
Can you not use a wildcard to move it all e.g.
mv file.tx* /new/
This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file
Hope that helps.
add a comment |Â
up vote
0
down vote
Can you not use a wildcard to move it all e.g.
mv file.tx* /new/
This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file
Hope that helps.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Can you not use a wildcard to move it all e.g.
mv file.tx* /new/
This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file
Hope that helps.
Can you not use a wildcard to move it all e.g.
mv file.tx* /new/
This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file
Hope that helps.
edited Nov 28 '16 at 16:13
answered Nov 28 '16 at 15:25
a.smith
1481213
1481213
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f326465%2fmove-multiple-files-with-same-name-in-same-directory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Thanks @icarus. Have updated the description with a detailed scenario.
â Dud
Nov 28 '16 at 2:44
Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
â icarus
Nov 28 '16 at 2:47
Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
â Dud
Nov 28 '16 at 2:52
1
Because you have a fixed filename, the FTP process will overwrite the previous
input.txt
, so you will only have a single file calledinput.txt
at a time (which will be the most recent one).â icarus
Nov 28 '16 at 3:02