0

I'm trying to copy all files like this:

...
dialogue022-en.txt
dialogue023-en.txt
dialogue024-en.txt
...

into files like this:

...
dialogue022-pivot.txt
dialogue023-pivot.txt
dialogue024-pivot.txt
...

2 Answers 2

1

To perform the copy, simply use:

for i in dialogue*-en.txt; do cp "$i" "${i/-en.txt}"-pivot.txt;done

Or, to see the commands first, use:

for i in dialogue*-en.txt; do echo cp "$i" "${i/-en.txt}"-pivot.txt;done

The part after the slash simply indicates the string that should be substracted from the original filename.

Kudos to https://unix.stackexchange.com/questions/122605/how-do-i-copy-multiple-files-by-wildcard

0

You can use regular expressions instead with JREN.BAT like this:

jren "^(dialogue-\d*-)en(\.txt)$" "$1pivot$2"

Steps:

  1. Copy all the code from this page's post, open notepad and save as jren.txt in the same folder you have those files.
  2. Rename jren.txt to jren.bat
  3. Open cmd by pressing Windows(Button)+R and type cmd and go to the folder your files are with cd c:\wheremyfilesare (or just right click the folder in Windows Explorer while pressing shift and choose to "open command line here")
  4. Copy and paste that line above into the command line and voilá!

I got to know JREN through dbenham and it works very well.

Edit

Warning: this renames the files, so you should copy them first to another folder if you want to keep both files. Just in case, if that forum goes offline I placed the jren code in here for download.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .