Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Using Vim or Ex to rename all files in a folder Post 302451431 by VimNewUser on Tuesday 7th of September 2010 12:25:54 AM
Old 09-07-2010
I tried a few variations on mv *apples* *oranges* but I can't get it to work. Is that what you mean?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

rename files in a folder

i have a folder that contains 100's of files: abc, bca, def, ghi.... i want to rename abc with 1, bca with 2, def with 3, ghi with 4 and so on. my way, i create a file.txt with contents: 1 2 3 4 i use while loop to rename my files. without using file.txt, i just want to rename abc with... (4 Replies)
Discussion started by: tjmannonline
4 Replies

2. Shell Programming and Scripting

rename all the files in a folder..

Hi Guys, I have 5000 files in a folder. all are .DAT files. I want to rename them as .TXT files. I tried the following command. mv *.DAT *. TXT But it is throwing an error. Can you please tell me what am i doing wrong. Thanks & Regards, Magesh. (11 Replies)
Discussion started by: mac4rfree
11 Replies

3. Shell Programming and Scripting

Rename folder based on containing XML file

Hi everyone. I'm in need of a solution where i need to rename a folder to a name that's inside an XML file in that folder. OS is Ubuntu 9.10 with Gnome. I've tried using grep, sed and xpath, but can't seem to find a solution. This is the simplified folder structure: FOLDER-NAME -... (4 Replies)
Discussion started by: CoolCow
4 Replies

4. Shell Programming and Scripting

Copy files from folder and rename them

hello, I need to build a shell script that receives the folder to copy by parameter and copy all files except thumb.db to another folder and rename them like, file.jpg renamed to file_bb1.jpg. can someone help me Thanks (4 Replies)
Discussion started by: zeker
4 Replies

5. Linux

rename files in a folder with date&time stamp

Hi, I want to rename all the files (more than 100 files) in a fodler to another folder with date&time stamp. foe eg, file1.dat file2.dat file3.dat .. to be renamed as file1100629_16_30_15.txt (yy-mon-dd_hh_mi_ss) file1100629_16_30_16.txt .. so on (2 Replies)
Discussion started by: feroz
2 Replies

6. UNIX for Dummies Questions & Answers

Bash script to rename all files within a folder...

Hi. I don't have any experience with making scripts in bash. I need a simple script to rename all files in a folder to the format file1.avi, file2.avi, file3.avi, and so on..... Please note that the original files have different filenames and different extensions. But they all need to be... (2 Replies)
Discussion started by: dranzer
2 Replies

7. Shell Programming and Scripting

sed to rename files in a folder - please help with script

Hello, I am new to shell scripting and stuck on renaming files in a folder. The files have the format chp01_00001.wav chp01_00002.wav .... chp02_00001.wav chp02_00002.wav .... but I want them to have the following names: chp_bloomy_00001.wav chp_bloomy_00002.wav chp_bloomy_00003.wav... (8 Replies)
Discussion started by: Bloomy
8 Replies

8. UNIX for Dummies Questions & Answers

looping through files, doing something, and rename in new folder

Hi, I'm really new at this but have several hundred files that i need to do something with and save with a new name. The files are 26 columns wide. I want to select some for renaming. I've figured out what to do to each file ("file-1.CSV"| grep -v "=" | cut -f 1-4,9,14,15,18,19,20,21,22,24,26... (2 Replies)
Discussion started by: bob101
2 Replies

9. Shell Programming and Scripting

Rename folder

hi guys i have a group of directory like these p1( 15 - 16 ) p2( 17 -15 ) p1 ( 14 - 20 ) p2 ( 13 -17 ) .. . . directories contain numbers represent time i want to rename all directories and change all numbers in directories' name . for example p1( 15 -16 ) will change to... (16 Replies)
Discussion started by: mhs
16 Replies

10. Shell Programming and Scripting

How to rename all files and folder containing underscore?

I want to rename all files and folder containing underscore in name and replace underscore with hyphen. Currently I am using following code, rename '_' '-' */*/* It was working but now it is showing me "Argument list too long" Please help! (2 Replies)
Discussion started by: opticalpigion
2 Replies
HTML::FormHandler::Field::Select(3pm)			User Contributed Perl Documentation		     HTML::FormHandler::Field::Select(3pm)

NAME
HTML::FormHandler::Field::Select - select fields VERSION
version 0.40013 DESCRIPTION
This is a field that includes a list of possible valid options. This can be used for select and multiple-select fields. Widget type is 'select'. Because select lists and checkbox_groups do not return an HTTP parameter when the entire list is unselected, the Select field must assume that the lack of a param means unselection. So to avoid setting a Select field, it must be set to inactive, not merely not included in the HTML for a form. This field type can also be used for fields that use the 'radio_group' widget, and the 'checkbox_group' widget (for selects with multiple flag turned on, or that use the Multiple field). options The 'options' array can come from a number of different places: From a field declaration In a field declaration: has_field 'opt_in' => ( type => 'Select', widget => 'RadioGroup', options => [{ value => 0, label => 'No'}, { value => 1, label => 'Yes'} ] ); From a field class 'build_options' method In a custom field class: package MyApp::Field::WeekDay; use Moose; extends 'HTML::FormHandler::Field::Select'; .... sub build_options { my $i = 0; my @days = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ); return [ map { { value => $i++, label => $_ } } @days ]; } From a coderef supplied to the field definition has_field 'flim' => ( type => 'Select', options_method => &flim_options ); sub flim_options { <return options array> } From a form 'options_<field_name>' method or attribute has_field 'fruit' => ( type => 'Select' ); sub options_fruit { return ( 1 => 'apples', 2 => 'oranges', 3 => 'kiwi', ); } -- or -- has 'options_fruit' => ( is => 'rw', traits => ['Array'], default => sub { [1 => 'apples', 2 => 'oranges', 3 => 'kiwi'] } ); Notice that, as a convenience, you can return a simple array (or arrayref) for the options array in the 'options_field_name' method. The hashrefs with 'value' and 'label' keys will be constructed for you by FormHandler. From the database The final source of the options array is a database when the name of the accessor is a relation to the table holding the information used to construct the select list. The primary key is used as the value. The other columns used are: label_column -- Used for the labels in the options (default 'name') active_column -- The name of the column to be used in the query (default 'active') that allows the rows retrieved to be restricted sort_column -- The name of the column used to sort the options See also HTML::FormHandler::Model::DBIC, the 'lookup_options' method. Customizing options Additional attributes can be added in the options array hashref, by using the 'attributes' key. If you have custom rendering code, you can add any additional key that you want, of course. Note that you should *not* set 'checked' or 'selected' attributes in options. That is handled by setting a field default. An options array with an extra 'note' key: sub options_license { my $self = shift; return unless $self->schema; my $licenses = $self->schema->resultset('License')->search({active => 1}, {order_by => 'sequence'}); my @selections; while ( my $license = $licenses->next ) { push @selections, { value => $license->id, label => $license->label, note => $license->note }; } return @selections; } Setting the select element to disabled: sub options_license { my $self = shift; return unless $self->schema; my $licenses = $self->schema->resultset('License')->search(undef, {order_by => 'sequence'}); my @selections; while ( my $license = $licenses->next ) { push @selections, { value => $license->id, label => $license->label, attributes => { disabled => ($license->active == 0) ? 1 : 0 } }; } return @selections; } You can also devide the options up into option groups. See the section on rendering. Reloading options If the options come from the options_<fieldname> method or the database, they will be reloaded every time the form is reloaded because the available options may have changed. To prevent this from happening when the available options are known to be static, set the 'do_not_reload' flag, and the options will not be reloaded after the first time Sorting options The sorting of the options may be changed using a 'sort_options' method in a custom field class. The 'Multiple' field uses this method to put the already selected options at the top of the list. Note that this won't work with option groups. Attributes and Methods options This is an array of hashes for this field. Each has must have a label and value keys. options_method Coderef of method to return options multiple If true allows multiple input values size This can be used to store how many items should be offered in the UI at a given time. Defaults to 0. empty_select Set to the string value of the select label if you want the renderer to create an empty select value. This only affects rendering - it does not add an entry to the list of options. has_field 'fruit' => ( type => 'Select', empty_select => '---Choose a Fruit---' ); value_when_empty Usually the empty value is an empty arrayref. This attribute allows changing that. Used by SelectCSV field. label_column Sets or returns the name of the method to call on the foreign class to fetch the text to use for the select list. Refers to the method (or column) name to use in a related object class for the label for select lists. Defaults to "name" localize_labels For the renderers: whether or not to call the localize method on the select labels. Default is off. active_column Sets or returns the name of a boolean column that is used as a flag to indicate that a row is active or not. Rows that are not active are ignored. The default is "active". If this column exists on the class then the list of options will included only rows that are marked "active". The exception is any columns that are marked inactive, but are also part of the input data will be included with brackets around the label. This allows updating records that might have data that is now considered inactive. auto_widget_size This is a way to provide a hint as to when to automatically select the widget to display for fields with a small number of options. For example, this can be used to decided to display a radio select for select lists smaller than the size specified. See select_widget below. sort_column Sets or returns the column used in the foreign class for sorting the options labels. Default is undefined. If this column exists in the foreign table then labels returned will be sorted by this column. If not defined or the column is not found as a method on the foreign class then the label_column is used as the sort condition. select_widget If the widget is 'select' for the field then will look if the field also has a auto_widget_size. If the options list is less than or equal to the auto_widget_size then will return "radio_group" if multiple is false, otherwise will return "checkbox_group". as_label Returns the option label for the option value that matches the field's current value. Can be helpful for displaying information about the field in a more friendly format. This does a string compare. error messages Customize 'select_invalid_value' and 'select_not_multiple'. Though neither of these messages should really be seen by users in a properly constructed select. Rendering The 'select' field can be rendered by the 'Select', 'RadioGroup', and 'CheckboxGroup' widgets. 'RadioGroup' is for a single select, and 'CheckboxGroup' is for a multiple select. Option groups can be rendered by providing an options arrays with 'group' elements containing options: sub options_testop { ( { group => 'First Group', options => [ { value => 1, label => 'One' }, { value => 2, label => 'Two' }, { value => 3, label => 'Three' }, ], }, { group => 'Second Group', options => [ { value => 4, label => 'Four' }, { value => 5, label => 'Five' }, { value => 6, label => 'Six' }, ], }, ) } The select rendering widgets all have a 'render_option' method, which may be useful for situations when you want to split up the rendering of a radio group or checkbox group. Database relations Also see HTML::FormHandler::TraitFor::Model::DBIC. The single select is for a DBIC 'belongs_to' relation. The multiple select is for a 'many_to_many' relation. There is very limited ability to do multiple select with 'has_many' relations. It will only work in very specific circumstances, and requires setting the 'has_many' attribute to the name of the primary key of the related table. This is a somewhat peculiar data structure for a relational database, and may not be what you really want. A 'has_many' is usually represented with a Repeatable field, and may require custom code if the form structure doesn't match the database structure. See HTML::FormHandler::Manual::Cookbook. AUTHOR
FormHandler Contributors - see HTML::FormHandler COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Gerda Shank. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-25 HTML::FormHandler::Field::Select(3pm)
All times are GMT -4. The time now is 03:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy