Sponsored Content
Top Forums Shell Programming and Scripting Rename first N numeric strings in filename Post 303033794 by wisecracker on Thursday 11th of April 2019 05:11:50 PM
Old 04-11-2019
Also to add to Don's reply...

Just an observation.

Do we take it that the leading 5 digits only and NOT the whole filenames themselves determine the positional play.
if so what will happen if two or more end up with an identical 5 digit number from your random number generator?
If you have 9999 music files then this is a possibility...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Wanted to eliminate numeric part from a filename

Hi, I have a filename called XYZ12345.txt.I just want to eliminate numeric and have only XYZ.txt. How can i do it ? Regards, Sona. (8 Replies)
Discussion started by: Sona
8 Replies

2. Shell Programming and Scripting

rename multiple filename.45267.txt to >> filename.txt

i have several thousand files and in subdirs that are named file.46634.txt budget.75346.pdf etc i want to remove the number but retain the extension. it is always a 5 digit. thanks. (6 Replies)
Discussion started by: jason7
6 Replies

3. Shell Programming and Scripting

Grep and rename the filename

Hi All, Can you please help me. The situation is like this. There are many different file name in this directory. I have to grep all the file that the name start with "PTWO" and rename it to COM with the current date. This is the script that I have done and it hit an... (16 Replies)
Discussion started by: badbunny9316
16 Replies

4. UNIX for Dummies Questions & Answers

rename filename

Hi, I am pretty new to this. I have a condition where in I want to replace all files within a folder. All filenames with character "abc" would need to replaced with "xyz". eg: helloabcworld-->helloxyzworld helloworld-->helloworld ... ... Thanks in advance. (6 Replies)
Discussion started by: sakets_2000
6 Replies

5. Shell Programming and Scripting

Rename FileName in the Directory

In the Directory all the Files are following format. Filename_yyyymmdd_numbers.txt eg. file_name_20120106_015802.txt . I want to write the Shell script to rename all the file to file_name.txt.in the directory. Thanks Mani (5 Replies)
Discussion started by: gavemani
5 Replies

6. UNIX for Dummies Questions & Answers

sort files by numeric filename

dear all, i have .dat files named as: 34.dat 2.dat 16.dat 107.dat i would like to sort them by their filenames as: 2.dat 16.dat 34.dat 107.dat i have tried numerous combinations of sort and ls command (in vain) to obtain : 107.dat 16.dat 2.dat 34.dat (1 Reply)
Discussion started by: chen.xiao.po
1 Replies

7. UNIX for Advanced & Expert Users

query display number lines or records present in file only numeric value -without filename

Hi all Thanks in advance........... Please help me for this issue............ I have a file it has 11 records . I used the command like .... >$ wc -l file 11 file I'm getting output like 11 file (no.of records along with filename) here my requirement is, I want to display only... (3 Replies)
Discussion started by: ksrivani
3 Replies

8. UNIX for Dummies Questions & Answers

Listing numeric strings alone

i have a file called 'test.txt' which contains the below data. abc123 123445 123abc 23224q From the above data, i want to display the line which contains only numeric . So i have tried the below commands with sed sed -n '/^$/p' test.txt sed '/^$/!d' test.txt But it... (4 Replies)
Discussion started by: pandeesh
4 Replies

9. Shell Programming and Scripting

Sort log files based on numeric value in the filename

Hi, I have a list of log files as follows: name_date_0001_ID0.log name_date_0001_ID2.log name_date_0001_ID1.log name_date_0002_ID2.log name_date_0004_ID0.log name_date_0005_ID0.log name_date_0021_ID0.log name_date_0025_ID0.log .......................................... (4 Replies)
Discussion started by: alex2005
4 Replies

10. Shell Programming and Scripting

Add edited numeric strings in awk

I am using awk to sum up all amounts and at end print total. input: 10,250.00 20,103.15 expected output: 30353.15 code: {subtot=+$1} END{print subtot} The problem I encounter is it stops at commas and returns 30 as answer And if I use this code: {subtot=($1+0);subtot=+$1}... (9 Replies)
Discussion started by: paresh n doshi
9 Replies
The audio/video playlist management API.(3)			      libmtp			       The audio/video playlist management API.(3)

NAME
libmtp - The audio/video playlist management API. Functions LIBMTP_playlist_t * LIBMTP_new_playlist_t (void) void LIBMTP_destroy_playlist_t (LIBMTP_playlist_t *) LIBMTP_playlist_t * LIBMTP_Get_Playlist_List (LIBMTP_mtpdevice_t *) LIBMTP_playlist_t * LIBMTP_Get_Playlist (LIBMTP_mtpdevice_t *, uint32_t const) int LIBMTP_Create_New_Playlist (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *const) int LIBMTP_Update_Playlist (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *const) int LIBMTP_Set_Playlist_Name (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *) Detailed Description Function Documentation int LIBMTP_Create_New_Playlist (LIBMTP_mtpdevice_t *device, LIBMTP_playlist_t *constmetadata) This routine creates a new playlist based on the metadata supplied. If the tracks field of the metadata contains a track listing, these tracks will be added to the playlist. Parameters: device a pointer to the device to create the new playlist on. metadata the metadata for the new playlist. If the function exits with success, the playlist_id field of this struct will contain the new playlist ID of the playlist. o metadata->parent_id should be set to the parent (e.g. folder) to store this track in. Since some devices are a bit picky about where files are placed, a default folder will be chosen if libmtp has detected one for the current filetype and this parameter is set to 0. If this is 0 and no default folder can be found, the file will be stored in the root folder. o metadata->storage_id should be set to the desired storage (e.g. memory card or whatever your device presents) to store this track in. Setting this to 0 will store the track on the primary storage. Returns: 0 on success, any other value means failure. See Also: LIBMTP_Update_Playlist() LIBMTP_Delete_Object() References LIBMTP_mtpdevice_struct::default_music_folder, LIBMTP_mtpdevice_struct::default_playlist_folder, LIBMTP_playlist_struct::name, LIBMTP_playlist_struct::no_tracks, LIBMTP_playlist_struct::parent_id, LIBMTP_playlist_struct::playlist_id, LIBMTP_playlist_struct::storage_id, LIBMTP_playlist_struct::tracks, and LIBMTP_mtpdevice_struct::usbinfo. void LIBMTP_destroy_playlist_t (LIBMTP_playlist_t *playlist) This destroys a playlist metadata structure and deallocates the memory used by it, including any strings. Never use a track metadata structure again after calling this function on it. Parameters: playlist the playlist metadata to destroy. See Also: LIBMTP_new_playlist_t() References LIBMTP_playlist_struct::name, and LIBMTP_playlist_struct::tracks. LIBMTP_playlist_t* LIBMTP_Get_Playlist (LIBMTP_mtpdevice_t *device, uint32_t constplid) This function retrieves an individual playlist from the device. Parameters: device a pointer to the device to get the playlist from. plid the unique ID of the playlist to retrieve. Returns: a valid playlist metadata post or NULL on failure. See Also: LIBMTP_Get_Playlist_List() References LIBMTP_new_playlist_t(), LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo. LIBMTP_playlist_t* LIBMTP_Get_Playlist_List (LIBMTP_mtpdevice_t *device) This function returns a list of the playlists available on the device. Typical usage: Parameters: device a pointer to the device to get the playlist listing from. Returns: a playlist list on success, else NULL. If there are no playlists on the device, NULL will be returned as well. See Also: LIBMTP_Get_Playlist() References LIBMTP_new_playlist_t(), LIBMTP_playlist_struct::name, LIBMTP_playlist_struct::next, LIBMTP_playlist_struct::no_tracks, LIBMTP_mtpdevice_struct::params, LIBMTP_playlist_struct::parent_id, LIBMTP_playlist_struct::playlist_id, LIBMTP_playlist_struct::storage_id, LIBMTP_playlist_struct::tracks, and LIBMTP_mtpdevice_struct::usbinfo. LIBMTP_playlist_t* LIBMTP_new_playlist_t (void) This creates a new playlist metadata structure and allocates memory for it. Notice that if you add strings to this structure they will be freed by the corresponding LIBMTP_destroy_playlist_t operation later, so be careful of using strdup() when assigning strings, e.g.: LIBMTP_playlist_t *pl = LIBMTP_new_playlist_t(); pl->name = strdup(str); .... LIBMTP_destroy_playlist_t(pl); Returns: a pointer to the newly allocated metadata structure. See Also: LIBMTP_destroy_playlist_t() References LIBMTP_playlist_struct::playlist_id. Referenced by LIBMTP_Get_Playlist(), and LIBMTP_Get_Playlist_List(). int LIBMTP_Set_Playlist_Name (LIBMTP_mtpdevice_t *device, LIBMTP_playlist_t *playlist, const char *newname) This function renames a single playlist object file holder. This simply means that the PTP_OPC_ObjectFileName property is updated, if this is supported by the device. The playlist filename should nominally end with an extension like '.pla'. NOTE: if you want to change the metadata the device display about a playlist you must not use this function, use LIBMTP_Update_Playlist() instead! Parameters: device a pointer to the device that contains the file. playlist the playlist metadata of the playlist to rename. On success, the name member is updated. Be aware, that this name can be different than newname depending of device restrictions. newname the new name for this object. Returns: 0 on success, any other value means failure. See Also: LIBMTP_Update_Playlist() References LIBMTP_playlist_struct::name, and LIBMTP_playlist_struct::playlist_id. int LIBMTP_Update_Playlist (LIBMTP_mtpdevice_t *device, LIBMTP_playlist_t *constmetadata) This routine updates a playlist based on the metadata supplied. If the tracks field of the metadata contains a track listing, these tracks will be added to the playlist in place of those already present, i.e. the previous track listing will be deleted. For Samsung devices the playlist id (metadata->playlist_id) is likely to change. Parameters: device a pointer to the device to create the new playlist on. metadata the metadata for the playlist to be updated. notice that the field playlist_id must contain the apropriate playlist ID. Playlist ID be modified to a new playlist ID by the time the function returns since edit-in-place is not always possible. Returns: 0 on success, any other value means failure. See Also: LIBMTP_Create_New_Playlist() LIBMTP_Delete_Object() References LIBMTP_playlist_struct::name, LIBMTP_playlist_struct::no_tracks, LIBMTP_playlist_struct::playlist_id, LIBMTP_playlist_struct::tracks, and LIBMTP_mtpdevice_struct::usbinfo. Author Generated automatically by Doxygen for libmtp from the source code. Version 1.1.3 Sun Feb 17 2013 The audio/video playlist management API.(3)
All times are GMT -4. The time now is 08:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy