Score:0

Create a script to rename a file, by first creating a filename using custom parameters from terminal

cn flag

Lets consider that the output of my every custom execution (some software in linux), gets saved in a generic filename /mydump/xyz.out. Instead of custom naming every output file, I want to write a script which does the following:-

  1. navigates to /mydump (cd mydump)
  2. creates a filename using arguments passed eg. config1_config2xconfig3.out
  3. renames xyz.out to config1_config2xconfig3.out (mv xyz.out "configbasedfilename")

For this what I understand is I should create some function in a script file, eg. custom_rename () and call it with config1-2-3 from the terminal whenever I wish to rename.

eg:- $custom_rename config1 config2 config3
or $ ./custom_rename.csh config1 config2 config3

or whatever makes sense.

Andrew Richards avatar
in flag
Yes that's right, but I struggle to understand what your actual question is.
NotTheDr01ds avatar
vn flag
Welcome to Ask Ubuntu! I agree with @AndrewRichards here -- It's unclear given the way your post is worded exactly what question you have. Are you looking for assistance with a script? Simply validation that you are on the right track? The best way to do it? (Note, "best way" is off-topic as "Subjective"/"Opinion-based", though). Please edit your post to clarify your question. Thanks!
Score:1
zw flag

You could write your own, probably limited script. Why not use "Bulk-rename" or similar packages, that are readily available?

[1]

There are more tools available. I wouldn't write anything myself...

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.