<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to copy and rename files in a one shot command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107185#M445360</link>
    <description>Hi&lt;BR /&gt;&lt;BR /&gt;I've 100 files with the txt extension. &lt;BR /&gt;I'd like to copy all this files in a ./bkp/ directory with another extension. &lt;BR /&gt;&lt;BR /&gt;I could write a script to do this but is exists an Unix commnand able to do this:&lt;BR /&gt;&lt;BR /&gt;of course cp *.txt ./bkp/*.txt.001 doesn't work. &lt;BR /&gt;&lt;BR /&gt;Any idea ?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Den&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 05 May 2008 23:50:01 GMT</pubDate>
    <dc:creator>Leo The Cat</dc:creator>
    <dc:date>2008-05-05T23:50:01Z</dc:date>
    <item>
      <title>How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107185#M445360</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I've 100 files with the txt extension. &lt;BR /&gt;I'd like to copy all this files in a ./bkp/ directory with another extension. &lt;BR /&gt;&lt;BR /&gt;I could write a script to do this but is exists an Unix commnand able to do this:&lt;BR /&gt;&lt;BR /&gt;of course cp *.txt ./bkp/*.txt.001 doesn't work. &lt;BR /&gt;&lt;BR /&gt;Any idea ?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Den&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 05 May 2008 23:50:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107185#M445360</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-05-05T23:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107186#M445361</link>
      <description>No, there is no way to do this without a loop. The reason is that cp has specific format requirements. The way to how confused cp would be with your command is to display what the shell is seeing after processing the filename expansion:&lt;BR /&gt; &lt;BR /&gt;echo "cp *.txt ./bkp/*.txt.001"&lt;BR /&gt; &lt;BR /&gt;The shell does not carry anything from the front of the list to the destination. The shell would be trying to run a command like this:&lt;BR /&gt; &lt;BR /&gt;cp 1.txt 2.txt 3.txt 4.txt ./bkp/*.txt.001&lt;BR /&gt; &lt;BR /&gt;where the "*" cannot be expanded so it just becomes the new name of the file: *.txt.001&lt;BR /&gt; &lt;BR /&gt;But, there is no need to write a script at all -- do everything from the command line:&lt;BR /&gt; &lt;BR /&gt;for FILE in *.txt &lt;BR /&gt;do&lt;BR /&gt;cp $FILE ./bkp/${FILE}.001&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Type everything at the command line. What you will see is:&lt;BR /&gt; &lt;BR /&gt;# for FILE in *.txt &lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; cp $FILE ./bkp/${FILE}.001&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;#&lt;BR /&gt; &lt;BR /&gt;where &amp;gt; is the PS2 prompt which indicates that the shell wants more to continue. When the last line is typed, the entire command line is run.</description>
      <pubDate>Tue, 06 May 2008 01:17:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107186#M445361</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2008-05-06T01:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107187#M445362</link>
      <description>hi Den,&lt;BR /&gt;&lt;BR /&gt;you could also TAR them to bkp directory as follows:&lt;BR /&gt;&lt;BR /&gt;tar -cvf ./bkp/ALLFILES-$(date +%H%M-%y%m%d).TAR ./*.txt&lt;BR /&gt;&lt;BR /&gt;This will allow you to tar all files into one file and which would look as follows:&lt;BR /&gt;&lt;BR /&gt;ALLFILES-0910-080506.TAR&lt;BR /&gt;&lt;BR /&gt;i.e. Backup of all file as at 09:10 today 06/05/2008&lt;BR /&gt;&lt;BR /&gt;hope this helps too!&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Tue, 06 May 2008 04:13:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107187#M445362</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2008-05-06T04:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107188#M445363</link>
      <description>Hi Den&lt;BR /&gt;do the following&lt;BR /&gt;&lt;BR /&gt;save all file name in a file example filelist&lt;BR /&gt;&lt;BR /&gt;ls *.txt &amp;gt; filelist&lt;BR /&gt;&lt;BR /&gt;then do the following&lt;BR /&gt;for i in `cat filelist`&lt;BR /&gt;do&lt;BR /&gt;cp $i /backup/$i.txt1 ( or whatever you want)&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Safar&lt;BR /&gt;</description>
      <pubDate>Tue, 06 May 2008 05:42:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107188#M445363</guid>
      <dc:creator>Safarali</dc:creator>
      <dc:date>2008-05-06T05:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107189#M445364</link>
      <description>Hi Den,&lt;BR /&gt;&lt;BR /&gt;Little bit fine tuned from the above posts:&lt;BR /&gt;&lt;BR /&gt;for i in `ls -1 *txt`&lt;BR /&gt;do&lt;BR /&gt;cp $i ./bkp/$i.001&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Rasheed Tamton.</description>
      <pubDate>Tue, 06 May 2008 05:52:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107189#M445364</guid>
      <dc:creator>Rasheed Tamton</dc:creator>
      <dc:date>2008-05-06T05:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107190#M445365</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I could write a script to do this&lt;BR /&gt;&lt;BR /&gt;This is what you should do until you feel comfortable with one liners.&lt;BR /&gt;&lt;BR /&gt;Bill has the right solution but you may want to use something like the following to test it:&lt;BR /&gt;for FILE in *.txt; do&lt;BR /&gt;   echo cp $FILE ./bkp/${FILE}.001&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Remove the echo if you have it as you want.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Rasheed: Little bit fine tuned from the above posts:&lt;BR /&gt;for i in `ls -1 *txt`&lt;BR /&gt;&lt;BR /&gt;While this is much better than Safar's, it can't beat Bill's.  And there is no reason to use ls(1).</description>
      <pubDate>Tue, 06 May 2008 09:22:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107190#M445365</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-05-06T09:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107191#M445366</link>
      <description>I haven't used either of these but I've heard people say good things about a utility called mmv.&lt;BR /&gt;&lt;BR /&gt;But apparently the perl "rename" is even better.&lt;BR /&gt;&lt;BR /&gt;As the quote from &lt;A href="http://www.phys.unsw.edu.au/~mcba/newunix/node6.html" target="_blank"&gt;http://www.phys.unsw.edu.au/~mcba/newunix/node6.html&lt;/A&gt; mentions.&lt;BR /&gt;&lt;BR /&gt;Hope this is useful.&lt;BR /&gt;&lt;BR /&gt;A more powerful alternative to mmv is rename, a perl script that uses regular expressions to provide extraordinary flexibility in changing filenames. For example, to convert filenames from uppercase to lowercase, you could do &lt;BR /&gt;&lt;BR /&gt;rename y/A-Z/a-z/ *&lt;BR /&gt;</description>
      <pubDate>Tue, 06 May 2008 10:16:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107191#M445366</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-05-06T10:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107192#M445367</link>
      <description>And then there's xargs&lt;BR /&gt;&lt;BR /&gt;Found this old code I had.  Believe it renames all the dat files found in a dir to dat.1 then dat.2 etc.&lt;BR /&gt;&lt;BR /&gt;Don't have access to a system to test right now...so TEST first :)&lt;BR /&gt;&lt;BR /&gt;Think its the last example below you need.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; $ ls&lt;BR /&gt;&amp;gt; a.dat b.dat c.dat&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt; To rename *.dat as *.dat.1&lt;BR /&gt;&amp;gt; $ ls *.dat | xargs -i mv {} {}.1&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt; But how to rename *.dat.1 as *.dat.2 using xargs?&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/bin/ls -1 ./*.1 | xargs -l -i sh -c 'mv "$1" "`basename \"$1\" .1`.&lt;BR /&gt;2"' '{}' '{}' \;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 May 2008 10:24:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107192#M445367</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-05-06T10:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107193#M445368</link>
      <description>You can download the MMV utility for HP from the Porting and Archive center for HP-UX.  Looks like an old version though.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/mmv-1.01b/" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/mmv-1.01b/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Some other sites with mmv (Don't know if good for HP-UX though)&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://pkgsrc.se/misc/mmv" target="_blank"&gt;http://pkgsrc.se/misc/mmv&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://openports.se/misc/mmv" target="_blank"&gt;http://openports.se/misc/mmv&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 May 2008 10:27:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107193#M445368</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-05-06T10:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107194#M445369</link>
      <description>&amp;gt; No, there is no way to do this without a&lt;BR /&gt;&amp;gt; loop.  [...]&lt;BR /&gt;&lt;BR /&gt;You're counting "find -exec" as a loop?  It's&lt;BR /&gt;certainly not a "for" loop.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; And then there's xargs&lt;BR /&gt;&lt;BR /&gt;or "find -exec":&lt;BR /&gt;&lt;BR /&gt;find -name '*.txt' -exec mv {} ./bkp/{}.001 \;&lt;BR /&gt;&lt;BR /&gt;(That's untested, but plausible.)&lt;BR /&gt;&lt;BR /&gt;There is seldom only one way to solve a&lt;BR /&gt;problem like this.</description>
      <pubDate>Tue, 06 May 2008 11:02:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107194#M445369</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-05-06T11:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy and rename files in a one shot command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107195#M445370</link>
      <description>First of all, thank you very much guys !&lt;BR /&gt;good posts and very good answers. &lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Den</description>
      <pubDate>Tue, 06 May 2008 12:51:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-copy-and-rename-files-in-a-one-shot-command/m-p/5107195#M445370</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-05-06T12:51:38Z</dc:date>
    </item>
  </channel>
</rss>

