<?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: Help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878991#M69413</link>
    <description>for FILE in *&lt;BR /&gt;do&lt;BR /&gt;mv $FILE subject_${FILE}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;when you're in the directory with the 'bunch of files'.</description>
    <pubDate>Sun, 09 Jan 2005 19:17:16 GMT</pubDate>
    <dc:creator>Stuart Browne</dc:creator>
    <dc:date>2005-01-09T19:17:16Z</dc:date>
    <item>
      <title>Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878990#M69412</link>
      <description>I have a bunch of files that I need to add a common pharse at the beginning of each file name.  What command should I use to run this for a bunch of files?&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;67898.txt&lt;BR /&gt;subject_67898.txt (I want to add subject to every file name)&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Sun, 09 Jan 2005 17:56:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878990#M69412</guid>
      <dc:creator>Shaf_1</dc:creator>
      <dc:date>2005-01-09T17:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878991#M69413</link>
      <description>for FILE in *&lt;BR /&gt;do&lt;BR /&gt;mv $FILE subject_${FILE}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;when you're in the directory with the 'bunch of files'.</description>
      <pubDate>Sun, 09 Jan 2005 19:17:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878991#M69413</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2005-01-09T19:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878992#M69414</link>
      <description>&lt;BR /&gt;Here is a classic perl script (with some examples to get you started) that I use for renaming files. &lt;BR /&gt;&lt;BR /&gt;================================&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;# rename - rename files with a Perl expression&lt;BR /&gt;#&lt;BR /&gt;# This is a very short and simple but powerful script for renaming files.&lt;BR /&gt;# The script iterates through the @ARGV array and uses Perl's built-in&lt;BR /&gt;# rename function rename one file at a time according to a Perl statement&lt;BR /&gt;# that is entered by the user at the time the program is executed.&lt;BR /&gt;# The script uses eval to compile and execute a user-supplied string used&lt;BR /&gt;# to control renaming of the files.&lt;BR /&gt;#&lt;BR /&gt;#########################################################################&lt;BR /&gt;#&lt;BR /&gt;# Example 1&lt;BR /&gt;#&lt;BR /&gt;# rename 's/\.orig$//' *.orig&lt;BR /&gt;#&lt;BR /&gt;# Example 1 uses a substitute operator to change $_ and eliminate the&lt;BR /&gt;# string '.orig' appearing at the end of each file name.&lt;BR /&gt;#&lt;BR /&gt;#------------------------------------------------------------------------&lt;BR /&gt;#&lt;BR /&gt;# Example 2&lt;BR /&gt;#&lt;BR /&gt;# rename 'y/A-Z/a-z/ unless /^Make/' *&lt;BR /&gt;#&lt;BR /&gt;# Example 2 uses Perl's y operator to change all uppercase characters to&lt;BR /&gt;# lowercase characters in $_, with the trailing condition that this only&lt;BR /&gt;# be done if the file name starts with 'Make'.&lt;BR /&gt;#&lt;BR /&gt;#------------------------------------------------------------------------&lt;BR /&gt;#&lt;BR /&gt;# Example 3&lt;BR /&gt;#&lt;BR /&gt;# rename '$_ .= ".bad"' *.f&lt;BR /&gt;#&lt;BR /&gt;# Example 3 concatenates a '.bad' extention onto each file name.&lt;BR /&gt;#&lt;BR /&gt;#------------------------------------------------------------------------&lt;BR /&gt;#&lt;BR /&gt;# Example 4&lt;BR /&gt;#&lt;BR /&gt;# rename 'print "$_: "; s /foo/bar/ if &lt;STDIN&gt; =~ /^y/i' *&lt;BR /&gt;#&lt;BR /&gt;# Example 4 prompts the user with each file name abd reads the user response&lt;BR /&gt;# from the standard input. If the user's response starts with 'y' or 'Y',&lt;BR /&gt;# then a substitute operator changes 'foo' to 'bar' in the file name.&lt;BR /&gt;#&lt;BR /&gt;#------------------------------------------------------------------------&lt;BR /&gt;#&lt;BR /&gt;# Example 5&lt;BR /&gt;#&lt;BR /&gt;# find /tmp -name '*~' -print | rename 's|^(.*)/(.+)~$|$1/.#$2|'&lt;BR /&gt;#&lt;BR /&gt;# Example 5 demonstrates that the rename script can also receive its list&lt;BR /&gt;# of file names from via the standard input instead of through command line&lt;BR /&gt;# arguments. The find command is used to search for files under the /tmp&lt;BR /&gt;# directory whose names end with a '~'. These are backup files created by&lt;BR /&gt;# the emacs editor. The find command prints the pathnames to all such files&lt;BR /&gt;# and pipes this list of pathnames to the rename script. The rename script&lt;BR /&gt;# uses a substitute operator to capture everything in the file name leading&lt;BR /&gt;# up to the final '~' and renames the file with a '.#' prefix and no '~' at&lt;BR /&gt;# the end. For example a file called /tmp/d/myfile~ is renamed to&lt;BR /&gt;# /tmp/d/.#myfile&lt;BR /&gt;#&lt;BR /&gt;#------------------------------------------------------------------------&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;# use shift to extract the first command line argument - this is the string&lt;BR /&gt;# containing the Perl statement(s) to be compiled and executed.&lt;BR /&gt;# These Perl operations are stored in a $op variable.&lt;BR /&gt;&lt;BR /&gt;($op = shift) || die "Usage: rename expr [files]\n";&lt;BR /&gt;&lt;BR /&gt;chomp(@ARGV = &lt;STDIN&gt;) unless @ARGV;&lt;BR /&gt;&lt;BR /&gt;foreach (@ARGV) {&lt;BR /&gt;        # save the current file name in $was&lt;BR /&gt;        $was = $_;                              # $_ is the default loop variable&lt;BR /&gt;        eval $op;                               # compile and execute the Perl&lt;BR /&gt;                                                # operations submitted by the user&lt;BR /&gt;        die if $@;                              # means eval 'failed'&lt;BR /&gt;        rename($was, $_) unless $was eq $_;     # rename is a Perl built-in function&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;================================&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Ross&lt;/STDIN&gt;&lt;/STDIN&gt;</description>
      <pubDate>Sun, 09 Jan 2005 23:26:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878992#M69414</guid>
      <dc:creator>Ross Minkov</dc:creator>
      <dc:date>2005-01-09T23:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878993#M69415</link>
      <description>Thanks for the help!</description>
      <pubDate>Mon, 10 Jan 2005 01:01:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help/m-p/4878993#M69415</guid>
      <dc:creator>Shaf_1</dc:creator>
      <dc:date>2005-01-10T01:01:47Z</dc:date>
    </item>
  </channel>
</rss>

