<?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 Re: Using find command to add common suffix to all files. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282138#M34133</link>
    <description>Hi Danny:&lt;BR /&gt;&lt;BR /&gt;# find /path -type f -print|xargs -i mv {} {}.txt&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 07 Oct 2008 21:42:26 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2008-10-07T21:42:26Z</dc:date>
    <item>
      <title>Using find command to add common suffix to all files.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282133#M34128</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;I'm attempting to use the find command to list all files within a directory, add a ".txt" extension to their existing filenames. &lt;BR /&gt;&lt;BR /&gt;However, I got only a single file, and in another instance an error msg indicating that the files are similar. See output below.&lt;BR /&gt;bash-2.05$ ls -l&lt;BR /&gt;total 0&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 19:15 f1&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 19:15 f2&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 19:15 f3&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 19:15 f4&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 19:15 f5&lt;BR /&gt;bash-2.05$ find . -type f -name "f*" -exec mv {} "{}.txt" \;&lt;BR /&gt;bash-2.05$ ls -l&lt;BR /&gt;total 0&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 19:15 {}.txt&lt;BR /&gt;bash-2.05$&lt;BR /&gt;&lt;BR /&gt;bash-2.05$ find . -type f -name "f*" -exec mv {} "f*.txt" \;&lt;BR /&gt;mv: ./f*.txt and f*.txt are identical&lt;BR /&gt;bash-2.05$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I had to use these in the bash or perl scripts:&lt;BR /&gt;for i in `ls &lt;DIRNAME&gt;`&lt;BR /&gt;do&lt;BR /&gt;   mv $i $i.txt&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;OR:&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;#&lt;BR /&gt;use strict;&lt;BR /&gt;use File::Copy;&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;@ARGV&amp;gt;) {&lt;BR /&gt;    my $ori = $_;&lt;BR /&gt;    rename($ori, "$ori\.txt");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Could anyone show me how can I achieve the same as I did using the scripts, on a command line?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Danny&lt;BR /&gt;&lt;BR /&gt;&lt;/DIRNAME&gt;</description>
      <pubDate>Tue, 07 Oct 2008 10:30:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282133#M34128</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2008-10-07T10:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using find command to add common suffix to all files.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282134#M34129</link>
      <description>&lt;!--!*#--&gt;&amp;gt; [...]  -exec mv {} "{}.txt" \;&lt;BR /&gt;&lt;BR /&gt;Don't quote the "{}.txt"?  It makes sense to&lt;BR /&gt;quote a file name in a script, because the&lt;BR /&gt;name could include a space or other special&lt;BR /&gt;character, but if "find -exec" can't deal&lt;BR /&gt;with an unquoted&lt;BR /&gt;      {}.txt&lt;BR /&gt;then there's probably no hope for a plain&lt;BR /&gt;      {}&lt;BR /&gt;either, and you're using that already.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  mv $i $i.txt&lt;BR /&gt;&lt;BR /&gt;And in this script you quote nothing, so why&lt;BR /&gt;annoy the "find" command with quotation?</description>
      <pubDate>Tue, 07 Oct 2008 13:24:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282134#M34129</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-10-07T13:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using find command to add common suffix to all files.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282135#M34130</link>
      <description>HI Steven,&lt;BR /&gt;&lt;BR /&gt;I've tried unquoting the {}.txt as you've suggested. However, that did not work as it produced the same result as before:&lt;BR /&gt;&lt;BR /&gt;bash-2.05$ ls -l&lt;BR /&gt;total 0&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 23:50 f1&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 23:50 f2&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 23:50 f3&lt;BR /&gt;bash-2.05$ find . -type f -name "f*" -exec mv {} {}.txt \;&lt;BR /&gt;bash-2.05$ ls -l&lt;BR /&gt;total 0&lt;BR /&gt;-rw-r--r--   1 danny    nwwls          0 Oct  7 23:50 {}.txt&lt;BR /&gt;bash-2.05$&lt;BR /&gt;&lt;BR /&gt;Appreciate it if you could point to me where did I go wrong in this.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Danny</description>
      <pubDate>Tue, 07 Oct 2008 15:00:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282135#M34130</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2008-10-07T15:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using find command to add common suffix to all files.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282136#M34131</link>
      <description>Maybe you could do something like:&lt;BR /&gt;&lt;BR /&gt;for FILE in $(find . -type f -name "f*" )&lt;BR /&gt;do&lt;BR /&gt;mv ${FILE} ${FILE}.txt&lt;BR /&gt;done</description>
      <pubDate>Tue, 07 Oct 2008 18:57:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282136#M34131</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2008-10-07T18:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using find command to add common suffix to all files.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282137#M34132</link>
      <description>&lt;!--!*#--&gt;Oops.  "find" replaces "{}" only when it sees&lt;BR /&gt;it as a "command argument", that is, as an&lt;BR /&gt;isolated token.  "find" has enough&lt;BR /&gt;limitations that I don't see a good way to&lt;BR /&gt;avoid using a script (in some form or other).&lt;BR /&gt;&lt;BR /&gt;You could write a little script like this:&lt;BR /&gt;&lt;BR /&gt;sol# cat ../append_name.sh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;mv "$1" "${2}${3}"&lt;BR /&gt;&lt;BR /&gt;and then use it:&lt;BR /&gt;&lt;BR /&gt;sol# ls -l&lt;BR /&gt;total 6&lt;BR /&gt;-rw-r--r--   1 root     root           4 Oct  7 15:51 a&lt;BR /&gt;-rw-r--r--   1 root     root           4 Oct  7 15:51 b&lt;BR /&gt;-rw-r--r--   1 root     root           4 Oct  7 16:11 c c&lt;BR /&gt;&lt;BR /&gt;sol# find . -name '*' -exec ../append_name.sh {} {} '.txt' \;&lt;BR /&gt;&lt;BR /&gt;sol# ls -l&lt;BR /&gt;total 6&lt;BR /&gt;-rw-r--r--   1 root     root           4 Oct  7 15:51 a.txt&lt;BR /&gt;-rw-r--r--   1 root     root           4 Oct  7 15:51 b.txt&lt;BR /&gt;-rw-r--r--   1 root     root           4 Oct  7 16:11 c c.txt&lt;BR /&gt;&lt;BR /&gt;On the bright side, "find" does seem to pass&lt;BR /&gt;a funny file name (like "c c") as a unit, so&lt;BR /&gt;if the script quotes things properly, funny&lt;BR /&gt;file names won't (always) cause trouble.&lt;BR /&gt;&lt;BR /&gt;That was done on a Solaris system, but if&lt;BR /&gt;you've seen one UNIX, ...</description>
      <pubDate>Tue, 07 Oct 2008 20:15:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282137#M34132</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-10-07T20:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using find command to add common suffix to all files.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282138#M34133</link>
      <description>Hi Danny:&lt;BR /&gt;&lt;BR /&gt;# find /path -type f -print|xargs -i mv {} {}.txt&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 07 Oct 2008 21:42:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-find-command-to-add-common-suffix-to-all-files/m-p/4282138#M34133</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-07T21:42:26Z</dc:date>
    </item>
  </channel>
</rss>

