0

I want to copy the files from current folder to another location like (CURRENT FOLDER) file name like this (F0#CGDBANG000947532#) to another location like (\10.10.10.1\BasketsIn) with user name in the file name like (F0#CGDBANG000947532#logesh) at the end F0#CGDBANG000947532# copy to F0#CGDBANG000947532#username

thanks

3
  • Could you provide a little more detail? Are you just trying to copy one file? Or a whole set of files? Commented May 24, 2014 at 12:15
  • Your question is unclear! Commented May 24, 2014 at 12:26
  • I want to copy the files in current folder to another location like (CURRENT FOLDER) file name like this (F0#CGDBANG000947532#) to another location like (\\10.10.10.1\BasketsIn) with user name in the file name like (F0#CGDBANG000947532#logesh) at the end F0#CGDBANG000947532# copy to F0#CGDBANG000947532#username thanks Commented May 24, 2014 at 17:21

2 Answers 2

1

Easy:

copy "c:\A" "d:\%username%_A"

EDIT finally, after some of your comments here and in your other question, I understood your request (I think).

@echo off
for %%i in (%*) do if /i "%%~xi"==".eps" copy "%%i" "\\10.10.14.13\adman\in\displ\%%~ni%username%.%%~xi"
pause
Sign up to request clarification or add additional context in comments.

4 Comments

I want to copy the files in current folder to another location like (CURRENT FOLDER) file name like this (F0#CGDBANG000947532#) to another location like (\\10.10.10.1\BasketsIn) with user name in the file name like (F0#CGDBANG000947532#logesh) at the end F0#CGDBANG000947532# copy to F0#CGDBANG000947532#username thanks @Stephan
@Logesh: In your question, you are saying, ‘I want to change the selected file name…’ – and now it turns out you wanted to rename multiple files. Please edit your question to make your specific problem clear.
Just noticed your update. Could you explaing please why are you using %*? I mean, it's not as if the OP is specifying file names in the command line. Or am I missing something?
@AndriyM: from his comments to his other (very similar) question (stackoverflow.com/questions/23847967/batch-script-file-name) I guessed, he wants to select a file in windows explorer and process it with "Send To". So %1 would be the consequence. %* will make it possible to select several files and process them each. I think, that's what he want to do. Of course this is only a guess, because both of his questions are very unclear. So are his comments.
0

If your file names do not have an extension or if you want the user name to be appended after the very end of the name (i.e. even after the extension), you could just use the following simple command:

COPY * \10.10.10.1\BasketsIn\*%USERNAME%

where USERNAME is a system environment variable that resolves to the user name of the current user.

If, however, you have names with extensions and you want the user name to be appended after the file name but before the file extension, you could use the ? mask character like this:

COPY * \10.10.10.1\BasketsIn\???????????????????????????????%USERNAME%.*

Just make sure you have provided enough ?s to cover the longest possible name in your case. If you are interested, you can learn more about this method in this excellent, in-depth Super User answer by dbenham:

One more note: this method may not work as expected with file names that have "multiple" extensions, i.e. like some.txt.doc.

8 Comments

As you mentioned I have file names with extensions and I want the user name to be appended after the file name but before the file extension. But even when I add enough ??, it didn't take the full name. When I did it for (F0#CGDBANG000947532#.eps) I recd like (0#CGDBANG000947532#logesh.eps) without the First letter (F). Pls let me know where I go wrong..?
That's strange. The exact command as the one in my post (except the target path) worked perfectly well for me, and I tried it with file names like yours – no lost characters, the new names were same with the user name added. I tried changing the first mask, *, to F* – thought something weird could be happening if the first letter was specified explicitly, but no, there was nothing wrong again. I'm puzzled, but I do have suspicion that something might be going on after the copying or perhaps you mistakenly copied files that did not have the first F in their names?
Thanks a lot and it works fine. I need little more help in the same situation, like Black&white files should go to B/W folder and Colour files should copy to Colour Folder. From the file name we can distinguish B/W & Colour, as the 4th character of file name will C or B as per the file. Like (F0#CG or F0#BG)_ F0#CGDBANG000947532# & F0#BGDBANG000947532#... thanks a lot in advance
Ah, but that is a different problem now. It will be better if you create a new question for it. That'll increase your chances of getting a good suggestion. I'll be happy to take a look at it when I have time.
Sure I will post it... and thanks a lot for your help.. I want to learn batch script from start, where can I learn can u sugggest any..?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.