Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replacing char in filename scripts fails Post 302698183 by SailingDreams on Saturday 8th of September 2012 07:11:35 PM
Old 09-08-2012
Hi Pamu

I'd like to remove the white space, and then my plan is to modify the windows explorer names so that I can add more files

Eg. I'd like to change
<quote>----------+ 1 None 3647968 Jul 21 08:41 2012-07-21\ (1).JPG
----------+ 1 None 3635983 Jul 21 10:29 2012-07-21\ (2).JPG
----------+ 1 None 738515 Jul 21 10:34 2012-07-21\ (3).JPG</quote>

to
<quote>
----------+ 1 None 3647968 Jul 21 08:41 2012-07-21(0100).JPG
----------+ 1 None 3635983 Jul 21 10:29 2012-07-21(0200).JPG
----------+ 1 None 738515 Jul 21 10:34 2012-07-21(0300).JPG</quote>

with the zeros added, I can add other photos like
<quote>----------+ 1 None 3647968 Jul 21 08:41 2012-07-21(0101).JPG</quote>

and they will be in proper chronological sequence.

Hi Alister

Thanks for the welcome.

How do I modify my script to replace spaces?

Many thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

replacing all 4 first upper char of every rec to lowercase ?

I have a file where some records have been updated the wrong way and need to fix it quickly since the amount can be alot. Every record where any of the first 4 characters are in upper case need to be changed to lowercase. Records can have '#' in position-1 for comments. These musn't be... (2 Replies)
Discussion started by: Browser_ice
2 Replies

2. UNIX for Advanced & Expert Users

file <filename> fails

Hi Friends I tried to find the file type of a file on my linux machine by using the following command file xy.txt instead of getting the file type i got following message file: couldnot found any magic files! What is wrong on this how can i find the file type? Regards Shekar (2 Replies)
Discussion started by: kingskar
2 Replies

3. Programming

replacing char with string

how we can replace char with a string example char *a="a.s" so finally what i ant to do raplace a with ant and s sree so in my array a i want to store the value as "ant.sree" thank u in advance (1 Reply)
Discussion started by: phani_sree
1 Replies

4. Shell Programming and Scripting

Scripts fails if you change its code during the execution.

So a script is working properly (tested many times) , then you add a new fine piece of code ,finaly its fails generally with a syntax error at the last line of the script. :confused:... does anybody why this happens? >uname -a HP-UX test... (4 Replies)
Discussion started by: Klashxx
4 Replies

5. UNIX for Dummies Questions & Answers

How to copy/move to a file with a special character as the 1st char in the filename?

I am trying to create files with special characters in its filenames for testing purposes. This is on a Linux RHEL4 but this should also be applicable on a Unix shell. I am able to create files with special characters in the filenames...e.g. cp -pv foo.gif \*special.gif cp -pv foo.gif \... (6 Replies)
Discussion started by: sqa777
6 Replies

6. Shell Programming and Scripting

Replacing one Char in a string of variable length

Hi all, I am trying to find the best way of making a change to 1 char in a string, the string can be between 1 and 14 characters. I am reading a line in from a file which contains 012341231231:2:102939283:NNN: Require :NBN: 012838238232:3:372932:NNN: Require :NNB: I need to change 1 N or a... (8 Replies)
Discussion started by: nkwilliams
8 Replies

7. Shell Programming and Scripting

Reading a file and replacing char by position

Hi I'm looking for a way to read a text file that may contain 1000 records or more and each of these records has 460 characters. I need to read each record, and add a string of characters starting at position 256 for each record. Any suggestions using UNIX shell scripting. (4 Replies)
Discussion started by: macastor
4 Replies

8. UNIX for Dummies Questions & Answers

Replacing multiple special chars with single char

Hi I've a string . And i need to replace set of characters with a single character Means .. or . or ... and so on should be replaced with single % character Irrespective of number of dots in between the characters , those should be replaced with single % All the above strings should be... (3 Replies)
Discussion started by: smile689
3 Replies

9. UNIX for Dummies Questions & Answers

Replacing part of filename

Hi guys! I have quite a lot of files like all_10001_ct1212307460308.alf* and I want to get rid of the first number for all at once like: all_ct1212307460308.alf* How can I do this in the shell? (12 Replies)
Discussion started by: TimmyTiz
12 Replies

10. UNIX for Beginners Questions & Answers

Help with replacing a char

Hello All, I have a file as below . I want to convert the Y with numbers to H From 4, M11, P2521759, Y75,Y70,Y105,Y110,Y700,Y815,Y830,Y900,Y162,Y300, Y291,Y290,Y15,Y20, MR2716014,MR2617014, Yesterday,current 1,201012, 102032,1 11112,0 to 4, M11, P2521759,... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies
pods::SDL::Image(3pm)					User Contributed Perl Documentation				     pods::SDL::Image(3pm)

NAME
SDL::Image - Bindings for the SDL_Image library DESCRIPTION
SDL::Image allows you to load many different format of images into memory as an SDL::Surface. CATEGORY
Image SUPPORTED FORMATS
The following types are supported: TGA TrueVision Targa (MUST have .tga) BMP Windows Bitmap(.bmp) PNM Portable Anymap (.pnm) .pbm = Portable BitMap (mono) .pgm = Portable GreyMap (256 greys) .ppm = Portable PixMap (full color) XPM X11 Pixmap (.xpm) can be #included directly in code This is NOT the same as XBM(X11 Bitmap) format, which is for monocolor images. XCF GIMP native (.xcf) (XCF = eXperimental Computing Facility?) This format is always changing, and since there's no library supplied by the GIMP project to load XCF, the loader may frequently fail to load much of any image from an XCF file. It's better to load this in GIMP and convert to a better supported image format. PCX ZSoft IBM PC Paintbrush (.pcx) GIF CompuServe Graphics Interchange Format (.gif) JPG Joint Photographic Experts Group JFIF format (.jpg or .jpeg) TIF Tagged Image File Format (.tif or .tiff) LBM Interleaved Bitmap (.lbm or .iff) FORM : ILBM or PBM(packed bitmap), HAM6, HAM8, and 24bit types are not supported. PNG Portable Network Graphics (.png) XV ICO CUR LOADING METHODS
load my $surface = SDL::Image::load( $file ); $file Image file name to load a surface from. Load file for use as an image in a new SDL::Surface. This actually calls SDL::Image::load_typed_rw, with the file extension used as the type string. This can load all supported image files, including TGA as long as the filename ends with ".tga". It is best to call this outside of event loops, and rather keep the loaded images around until you are really done with them, as disk speed and image conversion to a surface is not that speedy. Note: If the image format loader requires initialization, it will attempt to do that the first time it is needed if you have not already called SDL::Image::init to load support for your image format. Note: If the image format supports a transparent pixel, SDL::Image will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling: SDL::Video::set_color_key my $image = SDL::Image::load( $some_png_file ); SDL::Video::set_color_key($image, SDL_RLEACCEL, $image->format->colorkey); Return An image as a SDL::Surface. NULL is returned on errors, such as no support built for the image, or a file reading error. Use SDL::get_error to get cause of error. load_typed_rw SDL::Image::load_typed_rw($src, $freesrc, $type); src The source SDL::RWops as a pointer. The image is loaded from this. freesrc A non-zero value mean is will automatically close/free the src for you. Since SDL Perl cannot handle the memory inside this function you would most likely want 1 here. type A string that indicates which format type to interpret the image as. Here is a list of the currently recognized strings (case is not important): "BMP" "CUR" "GIF" "ICO" "JPG" "LBM" "PCX" "PNG" "PNM" "TGA" "TIF" "XCF" "XPM" "XV" Load src for use as a surface. This can load all supported image formats. This method does not guarantee that the format specified by type is the format of the loaded image, except in the case when TGA format is specified (or any other non-magicable format in the future). Using SDL_RWops is not covered here, but they enable you to load from almost any source. Note: If the image format loader requires initialization, it will attempt to do that the first time it is needed if you have not already called SDL::Image::init to load support for your image format. Note: If the image format supports a transparent pixel, SDL::Image will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling: SDL::Video::set_color_key Transparency use SDL; use SDL::RWOps; use SDL::Image; my $file2 = SDL::RWOps->new_file("test/data/menu.png", "rb"); my $image = SDL::Image::load_typed_rw($file2, 1, "PNG"); SDL::Video::set_color_key($image, SDL_RLEACCEL, $image->format->colorkey); Return The image as a new SDL::Surface. NULL is returned on errors. is_[TYPE] Test for valid, supported image files: is_ICO is_CUR is_PNG is_BMP is_GIF is_JPG is_LBM is_PCX is_PNM is_TIF is_XCF is_XPM is_XV These functions take a SDL::RWOps as a parameter. Return 1 if the image is a valid [TYPE] and the [TYPE] format support is compiled into SDL_image. 0 is returned otherwise. Example use SDL::RWOps; use SDL::Image; my $file = SDL::RWOps->new_file("file", "rb"); print "Image is BMP" if ( SDL::is_BMP ); load_[TYPE]_rw Specific loader for known formats: load_ICO_rw load_CUR_rw load_PNG_rw load_BMP_rw load_GIF_rw load_JPG_rw load_LBM_rw load_PCX_rw load_PNM_rw load_TIF_rw load_XCF_rw load_XPM_rw load_XV_rw These functions take a SDL::RWop as a parameter Return The image as a new SDL::Surface. NULL is returned on errors, like if the [TYPE] is not supported, or a read error. Example use SDL; use SDL::RWOps; use SDL::Image; my $file = SDL::RWOps->new_file("file.png", "rb"); my $image = SDL::Image::load_PNG_rw($file); die SDL::get_error if (!$image); read_XPM_from_array my $picture = SDL::Image::read_XPM_from_array(@XPM, $width); This functions takes the reference of an array in the valid @XPM format. Also the $width of the XPM image. Return The image as a new SDL::Surface. NULL is returned on errors, like if XPM is not supported, or a read error. Example my @XPM= ( '30 30 9 1', ' c #FFFFFF', '. c #EFEFEF', '+ c #CFCFCF', '@ c #9F9F9F', '# c #808080', '$ c #505050', '% c #202020', '& c #000000', '* c #303030', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' .+@##@+. ', ' .@$%&&%$@. ', ' .@*&&&&&&*@. ', ' +$&&&&&&&&$+ ', ' @%&&&&&&&&%@ ', ' #&&&&&&&&&&# ', ' #&&&&&&&&&&# ', ' @%&&&&&&&&%@ ', ' +$&&&&&&&&$+ ', ' .@*&&&&&&*@. ', ' .@$%&&%$@. ', ' .+@##@+. ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',); my $picture = SDL::Image::read_XPM_from_array(@XPM, 30); MISC METHODS
linked_version Provides the version of linked sdl_image library. Return Returns a SDL::Version object Example my $version = SDL::Image::linked_version(); print $version->major.' '.$version->minor.' '.$version->patch; init For version SDL_image 1.2.10 and up Flags bitwise OR'd set of image formats to support by loading a library now. The values you may OR together to pass in are: IMG_INIT_JPG IMG_INIT_PNG IMG_INIT_TIF Initialize by loading support as indicated by the flags, or at least return success if support is already loaded. You may call this multiple times, which will actually require you to call IMG_Quit just once to clean up. You may call this function with a 0 to retrieve whether support was built-in or not loaded yet. Note: to load JPG, PNG, and/or TIF images you can call IMG_Init with the right IMG_INIT_* flags OR'd together before you program gets busy, to prevent a later hiccup while it loads the library, and to check that you do have the support that you need before you try and use it. Note: No initialization is needed nor performed when using the SDL::Image::is_JPG, SDL::Image::is_PNG, and SDL::Image::is_TIF functions. Note: this function does not always set the error string, so do not depend on SDL::Image::get_error being meaningful all the time. Return A bitmask of all the currently inited image loaders. Example use SDL::Image; my $flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_JPG; my $inited = SDL::Image::init($flags); quit For version SDL_image 1.2.10 and up This function cleans up all dynamically loaded library handles, freeing memory. If support is required again it will be initialized again, either by SDL::Image::init or loading an image with dynamic support required. You may call this function when SDL::Image::load functions are no longer needed for the JPG, PNG, and TIF image formats. You only need to call this function once, no matter how many times SDL::Image::init was called. Example use SDL::Image; SDL::Image::init(IMG_INIT_JPG); #loads JPG support SDL::Image::load("file.png"); #loads PNG support SDL::Image::quit(); #unloads everything set_error Same as SDL::set_error get_error Same as SDL::get_error SEE ALSO
SDL, SDL::Surface, SDL::Video, SDL::RWOps AUTHORS
See "AUTHORS" in SDL. perl v5.14.2 2012-05-28 pods::SDL::Image(3pm)
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy