How do I rename list of files with dateformat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do I rename list of files with dateformat
# 8  
Old 08-15-2012
Quote:
Originally Posted by RudiC
Then you are in the lucky position to tell stat how to output the date using your desired timefmt.

Accepted. Good point. Still my intention was to give ideas to the requestor on how to achieve the result so he/she can dream up a best fit solution.
Agreed. Apple's stat(1) man page's description of how to do this is rather opaque and doesn't include any examples for this issue. But the command:
Code:
stat -t "%Y%m%d" -f "%Sm%n" file

does give output in the format needed for this script (YYYYMMDD) on OS X (and would greatly simplify the script I provided).

Although this site's OpenSolaris 2009.06 Man Page Set includes a stat(1) man page, I can't find a stat(1) man page for Solaris 10 or 11 and I don't remember there being a stat utility on the Solaris systems I used to use.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

2. Shell Programming and Scripting

Rename files to match file list pattern

Hi All, I have 100 folders with the first delimiter has a unique name i.e (123_hello and 575_hello) and each folder have atlist 1000 plus files with naming convention i.e (575_hello_1.iso ... 575_hello_1000.iso). 575_hello/575_hello_1.iso 575_hello/575_hello_2.iso 575_hello/575_hello_3.iso... (8 Replies)
Discussion started by: lxdorney
8 Replies

3. UNIX for Dummies Questions & Answers

Rename files based on a list

Hi, I have a directory with a lot of files like this: a.bam b.bam c.bam I like to rename these files based on a list where the name of the files in the first column will be replasced by the names in the second column. Here is my list which is a tab-delimited text file: a x b y c ... (4 Replies)
Discussion started by: a_bahreini
4 Replies

4. Shell Programming and Scripting

Is better way copy list of multiple files, rename and gzip

Is better way to write the script loop through one by one "Old_File_1: & New_File_1:" to copy 100 files to /staging/test folder then re-name & gzip all those files? I wrote this code below and don't like that much. Thanks I have a control_file under /tmp/test folder like below 100 files and... (10 Replies)
Discussion started by: dotran
10 Replies

5. Shell Programming and Scripting

Datatype,structure and dateformat checking.

I have a sourcefile which contains data as below.I want to check whether datatype,structure and date format looks good as mentioned. Data is delemited by cydila Ç. Source file-Emp.txt snoÇnameÇphonenoÇdeptÇjoineddate 1ÇvivekÇ0861ÇCSEÇ2013-05-29 00:00:00 2ÇdineshÇ123456ÇECEÇ2013-05-29 00:00:00... (8 Replies)
Discussion started by: katakamvivek
8 Replies

6. Shell Programming and Scripting

How to Rename List of files in a directory

How can i rename list of files in a directory? (4 Replies)
Discussion started by: knip
4 Replies

7. Shell Programming and Scripting

Oracle DataBase DateFormat

I am currently writing a script in AIX I connected to the database using SQL *PLUS I need to retrive data of Number of rows inserted today in the table(TABLE_NAME) which has column DATETIME(DDMMYYYY) I tried using select TO_CHAR(sysdate, 'DDMMYYYY') CHRDATE from dual select count (*)... (2 Replies)
Discussion started by: PhAnT0M
2 Replies

8. Shell Programming and Scripting

Need to move and rename a list of files

Hi, I need to do something easy but I can't seem to figure out how to do this. Let's say I have 6 files in the directory below: /ebsbeta_f/flash/EBSUATQB/onlinelog o1_mf_6_55klt7nr_.log o1_mf_3_55klskj4_.log o1_mf_4_55klsrl1_.log o1_mf_5_55klt09p_.log o1_mf_2_55klv1ts_.log... (10 Replies)
Discussion started by: exm
10 Replies

9. Shell Programming and Scripting

please help - script to list and rename

Hi Friend, I have a small script to list all file FFAAAAABBBBB00001 and FFAAAAABBBBB00001.repaired (when I run another script, the orginal file will output another *.repaired file) in my unix directory, and reaname the output file FFAAAAABBBBB00001.repaired back to FFAAAABBBBB00001. However, it... (2 Replies)
Discussion started by: happyv
2 Replies

10. UNIX for Dummies Questions & Answers

copy and rename list of files

Hi all, I am a newbie in writng unix..I am using ksh shell..Does anyone know how to copy a list o files from directory A to directory B with differnt names? i.e in Dir A, I have RPT101.555.TXT RPT102.666.TXT and I want to copy those files to dir B with new naming convention.. in Dir B,... (7 Replies)
Discussion started by: kinmak
7 Replies
Login or Register to Ask a Question
GEMFILE(5)																GEMFILE(5)

NAME
Gemfile - A format for describing gem dependencies for Ruby programs SYNOPSIS
A Gemfile describes the gem dependencies required to execute associated Ruby code. Place the Gemfile in the root of the directory containing the associated code. For instance, in a Rails application, place the Gemfile in the same directory as the Rakefile. SYNTAX
A Gemfile is evaluated as Ruby code, in a context which makes available a number of methods used to describe the gem requirements. SOURCES (#source) At the top of the Gemfile, add one line for each Rubygems source that might contain the gems listed in the Gemfile. source "https://rubygems.org" source "http://gems.github.com" Each of these _source_s MUST be a valid Rubygems repository. Sources are checked for gems following the heuristics described in SOURCE PRI- ORITY. RUBY (#ruby) If your application requires a specific Ruby version or engine, specify your requirements using the ruby method, with the following argu- ments. All parameters are OPTIONAL unless otherwise specified. VERSION (required) The version of Ruby that your application requires. If your application requires an alternate Ruby engine, such as JRuby or Rubinius, this should be the Ruby version that the engine is compatible with. ruby "1.9.3" ENGINE (:engine) Each application may specify a Ruby engine. If an engine is specified, an engine version must also be specified. ENGINE VERSION (:engine_version) Each application may specify a Ruby engine version. If an engine version is specified, an engine must also be specified. If the engine is "ruby" the engine version specified must match the Ruby version. ruby "1.8.7", :engine => "jruby", :engine_version => "1.6.7" GEMS (#gem) Specify gem requirements using the gem method, with the following arguments. All parameters are OPTIONAL unless otherwise specified. NAME (required) For each gem requirement, list a single gem line. gem "nokogiri" VERSION Each gem MAY have one or more version specifiers. gem "nokogiri", ">= 1.4.2" gem "RedCloth", ">= 4.1.0", "< 4.2.0" REQUIRE AS (:require) Each gem MAY specify files that should be used when autorequiring via Bundler.require. You may pass an array with multiple files, or false to prevent any file from being autorequired. gem "redis", :require => ["redis/connection/hiredis", "redis"] gem "webmock", :require => false The argument defaults to the name of the gem. For example, these are identical: gem "nokogiri" gem "nokogiri", :require => "nokogiri" GROUPS (:group or :groups) Each gem MAY specify membership in one or more groups. Any gem that does not specify membership in any group is placed in the default group. gem "rspec", :group => :test gem "wirble", :groups => [:development, :test] The Bundler runtime allows its two main methods, Bundler.setup and Bundler.require, to limit their impact to particular groups. # setup adds gems to Ruby's load path Bundler.setup # defaults to all groups require "bundler/setup" # same as Bundler.setup Bundler.setup(:default) # only set up the _default_ group Bundler.setup(:test) # only set up the _test_ group (but `not` _default_) Bundler.setup(:default, :test) # set up the _default_ and _test_ groups, but no others # require requires all of the gems in the specified groups Bundler.require # defaults to just the _default_ group Bundler.require(:default) # identical Bundler.require(:default, :test) # requires the _default_ and _test_ groups Bundler.require(:test) # requires just the _test_ group The Bundler CLI allows you to specify a list of groups whose gems bundle install should not install with the --without option. To specify multiple groups to ignore, specify a list of groups separated by spaces. bundle install --without test bundle install --without development test After running bundle install --without test, bundler will remember that you excluded the test group in the last installation. The next time you run bundle install, without any --without option, bundler will recall it. Also, calling Bundler.setup with no parameters, or calling require "bundler/setup" will setup all groups except for the ones you excluded via --without (since they are obviously not available). Note that on bundle install, bundler downloads and evaluates all gems, in order to create a single canonical list of all of the required gems and their dependencies. This means that you cannot list different versions of the same gems in different groups. For more details, see Understanding Bundler http://gembundler.com/rationale.html. PLATFORMS (:platforms) If a gem should only be used in a particular platform or set of platforms, you can specify them. Platforms are essentially identical to groups, except that you do not need to use the --without install-time flag to exclude groups of gems for other platforms. There are a number of Gemfile platforms: ruby C Ruby (MRI) or Rubinius, but NOT Windows ruby_18 ruby AND version 1.8 ruby_19 ruby AND version 1.9 ruby_20 ruby AND version 2.0 mri Same as ruby, but not Rubinius mri_18 mri AND version 1.8 mri_19 mri AND version 1.9 mri_20 mri AND version 2.0 rbx Same as ruby, but only Rubinius (not MRI) jruby JRuby mswin Windows mingw Windows 'mingw32' platform (aka RubyInstaller) mingw_18 mingw AND version 1.8 mingw_19 mingw AND version 1.9 mingw_20 mingw AND version 2.0 As with groups, you can specify one or more platforms: gem "weakling", :platforms => :jruby gem "ruby-debug", :platforms => :mri_18 gem "nokogiri", :platforms => [:mri_18, :jruby] All operations involving groups (bundle install, Bundler.setup, Bundler.require) behave exactly the same as if any groups not matching the current platform were explicitly excluded. GIT (:git) If necessary, you can specify that a gem is located at a particular git repository. The repository can be public (http://github.com/rails/rails.git) or private (git@github.com:rails/rails.git). If the repository is private, the user that you use to run bundle install MUST have the appropriate keys available in their $HOME/.ssh. Git repositories are specified using the :git parameter. The group, platforms, and require options are available and behave exactly the same as they would for a normal gem. gem "rails", :git => "git://github.com/rails/rails.git" A git repository SHOULD have at least one file, at the root of the directory containing the gem, with the extension .gemspec. This file MUST contain a valid gem specification, as expected by the gem build command. It MUST NOT have any dependencies, other than on the files in the git repository itself and any built-in functionality of Ruby or Rubygems. If a git repository does not have a .gemspec, bundler will attempt to create one, but it will not contain any dependencies, executables, or C extension compilation instructions. As a result, it may fail to properly integrate into your application. If a git repository does have a .gemspec for the gem you attached it to, a version specifier, if provided, means that the git repository is only valid if the .gemspec specifies a version matching the version specifier. If not, bundler will print a warning. gem "rails", "2.3.8", :git => "git://github.com/rails/rails.git" # bundle install will fail, because the .gemspec in the rails # repository's master branch specifies version 3.0.0 If a git repository does not have a .gemspec for the gem you attached it to, a version specifier MUST be provided. Bundler will use this version in the simple .gemspec it creates. Git repositories support a number of additional options. branch, tag, and ref You MUST only specify at most one of these options. The default is :branch => "master" submodules Specify :submodules => true to cause bundler to expand any submodules included in the git repository If a git repository contains multiple .gemspecs, each .gemspec represents a gem located at the same place in the file system as the .gem- spec. |~rails [git root] | |-rails.gemspec [rails gem located here] |~actionpack | |-actionpack.gemspec [actionpack gem located here] |~activesupport | |-activesupport.gemspec [activesupport gem located here] |... To install a gem located in a git repository, bundler changes to the directory containing the gemspec, runs gem build name.gemspec and then installs the resulting gem. The gem build command, which comes standard with Rubygems, evaluates the .gemspec in the context of the direc- tory in which it is located. GITHUB (:github) If the git repository you want to use is hosted on GitHub and is public, you can use the :github shorthand to specify just the github user- name and repository name (without the trailing ".git"), separated by a slash. If both the username and repository name are the same, you can omit one. gem "rails", :github => "rails/rails" gem "rails", :github => "rails" Are both equivalent to gem "rails", :git => "git://github.com/rails/rails.git" PATH (:path) You can specify that a gem is located in a particular location on the file system. Relative paths are resolved relative to the directory containing the Gemfile. Similar to the semantics of the :git option, the :path option requires that the directory in question either contains a .gemspec for the gem, or that you specify an explicit version that bundler should use. Unlike :git, bundler does not compile C extensions for gems specified as paths. gem "rails", :path => "vendor/rails" BLOCK FORM OF GIT, PATH, GROUP and PLATFORMS The :git, :path, :group, and :platforms options may be applied to a group of gems by using block form. git "git://github.com/rails/rails.git" do gem "activesupport" gem "actionpack" end platforms :ruby do gem "ruby-debug" gem "sqlite3" end group :development do gem "wirble" gem "faker" end In the case of the git block form, the :ref, :branch, :tag, and :submodules options may be passed to the git method, and all gems in the block will inherit those options. GEMSPEC (#gemspec) If you wish to use Bundler to help install dependencies for a gem while it is being developed, use the gemspec method to pull in the depen- dencies listed in the .gemspec file. The gemspec method adds any runtime dependencies as gem requirements in the default group. It also adds development dependencies as gem requirements in the development group. Finally, it adds a gem requirement on your project (:path => '.'). In conjunction with Bundler.set- up, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths. The gemspec method supports optional :path, :name, and :development_group options, which control where bundler looks for the .gemspec, what named .gemspec it uses (if more than one is present), and which group development dependencies are included in. SOURCE PRIORITY
When attempting to locate a gem to satisfy a gem requirement, bundler uses the following priority order: 1. The source explicitly attached to the gem (using :path or :git) 2. For implicit gems (dependencies of explicit gems), any git or path repository otherwise declared. This results in bundler prioritizing the ActiveSupport gem from the Rails git repository over ones from rubygems.org 3. The sources specified via source, searching each source in your Gemfile from last added to first added. March 2013 GEMFILE(5)