Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Removing prefix from multiple files and renaming file extension Post 302324245 by rakeshawasthi on Wednesday 10th of June 2009 09:57:23 AM
Old 06-10-2009
Code:
for file in `ls pdb*.ent`
do
   new_name=`echo $file | sed 's/^pdb//;s/.ent/.txt/'`
   mv $file $new_name
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Renaming multiple files, to get rid of extension

I have a good script to rename multiple files, but what's the best way I can remove some text from multiple filenames? Say I have a directory with 35 files with a .XLS at the end, how can I rename them to remove the .XLS but keep everything the same, without having to mv manually. Thanks. (6 Replies)
Discussion started by: nj78
6 Replies

2. Shell Programming and Scripting

Help removing the prefix of more than 10,000 files

I have more than 10,000 files that all start with "raw_ddd_04_*". How can I remove the prefix on these files in a single command? (8 Replies)
Discussion started by: bbbngowc
8 Replies

3. Shell Programming and Scripting

removing a word in a multiple file starting at the dot extension

hi I would like to ask if someone knows a command or a script on how to rename a multiple file in the directory starting at the end of the filename or at the .extension( i would like to remove the last 11 character before the extension) for example Below is the result of my command ls inside... (5 Replies)
Discussion started by: jao_madn
5 Replies

4. UNIX for Dummies Questions & Answers

Rename multiple files, changing prefix, extension and dropping characters

I'm currently only able to perform some very basic functions, so hope this makes sense... I have a set of about 27 files that need to be renamed from something like this: 000012ABCDEFGHIJ.XXX.YYY.ZZZ 000078KLMNO.XXX.YYY.ZZZ 000099PQ.XXX.YYY.ZZZ to something like this: newa012.abc... (11 Replies)
Discussion started by: bbmcg
11 Replies

5. Shell Programming and Scripting

Renaming the extension of a set of files

Hi All, I am trying to rename the extension of a set of file from .txt to .xtx. When I run the following script, #!/bin/sh l=`ls /f` for f in $l do "mv $f ${f%.txt}.xtx" ; done a file such as 1.txt is renamed to 1? where ? is a strange character. Could you please help me fix the code... (3 Replies)
Discussion started by: sara123
3 Replies

6. Shell Programming and Scripting

Split a file into multiple files with an extension

Hi I have a file with 100 million rows. I want to split them into 1000 subfiles and name them from 1.xls to 1000.xls.. Can I do it in awk? Thanks, (8 Replies)
Discussion started by: Diya123
8 Replies

7. UNIX for Dummies Questions & Answers

Renaming Multiple Files by removing characters

Hi I would like to rename Multiple files in a Unix Directory using Ksh Command. Eg ATT8-2011-10-01 00:00:00-MSA-IMM-SINGLE_AND_FAMILY_COVERAGE-DED-$2000-X114817.PDF needs to be renamed as ATT8-2011-10-01-MSA-IMM-SINGLE_AND_FAMILY_COVERAGE-DED-$2000-X114817.PDF Basically the time... (2 Replies)
Discussion started by: pchegoor
2 Replies

8. Shell Programming and Scripting

Curl command to download multiple files with a file prefix

I am using the below curl command to download a single file from client server and it is working as expected curl --ftp-ssl -k -u ${USER}:${PASSWD} ftp://${HOST}:${PORT}/path/to/${FILE} --output ${DEST}/${FILE} let say the client has 3 files hellofile.101, hellofile.102, hellofile.103 and I... (3 Replies)
Discussion started by: r@v!7*7@
3 Replies

9. Shell Programming and Scripting

Copying multiple files and appending time stamp before file extension

Hi, I have multiple files that read: Asa.txt Bad.txt Gnu.txt And I want to rename them using awk to Asa_ddmmyytt.txt and so on ... If there is a single command or more efficient executable please share! Thanks! (4 Replies)
Discussion started by: Jesshelle David
4 Replies

10. Shell Programming and Scripting

Splitting file into multiple files and renaming them

Hi all, Newbie here. First of all, sorry if I made any mistakes while posting this question in terms of rules. Correct me if I am wrong. :b: I have a .dat file whose name is in the format of 20170311_abc_xyz.dat. The file consists of records whose first column consists of multiple dates in... (2 Replies)
Discussion started by: chanduris
2 Replies
Mail::SpamAssassin::AsyncLoop(3)			User Contributed Perl Documentation			  Mail::SpamAssassin::AsyncLoop(3)

NAME
Mail::SpamAssassin::AsyncLoop - scanner asynchronous event loop DESCRIPTION
An asynchronous event loop used for long-running operations, performed "in the background" during the Mail::SpamAssassin::check() scan operation, such as DNS blocklist lookups. METHODS
$obj = $async->start_lookup($obj) Register the start of a long-running asynchronous lookup operation. $obj is a hash reference containing the following items: key (required) A key string, unique to this lookup. This is what is reported in debug messages, used as the key for "get_lookup()", etc. id (required) An ID string, also unique to this lookup. Typically, this is the DNS packet ID as returned by DnsResolver's "bgsend" method. Sadly, the Net::DNS architecture forces us to keep a separate ID string for this task instead of reusing "key" -- if you are not using DNS lookups through DnsResolver, it should be OK to just reuse "key". type (required) A string, typically one word, used to describe the type of lookup in log messages, such as "DNSBL", "MX", "TXT". poll_callback (optional) A code reference, which will be called periodically during the background-processing period. If you will be performing an async lookup on a non-DNS-based service, you will need to implement this so that it checks for new responses and calls "set_response_packet()" or "report_id_complete()" as appropriate. DNS-based lookups can leave it undefined, since DnsResolver::poll_responses() will be called automatically anyway. The code reference will be called with one argument, the $ent object. completed_callback (optional) A code reference which will be called when an asynchronous task (e.g. a DNS lookup) is completed, either normally, or aborted, e.g. by a timeout. When a task has been reported as completed via "set_response_packet()" the response (as provided to "set_response_packet()") is stored in $ent->{response_packet} (possibly undef, its semantics is defined by the caller). When completion is reported via "report_id_complete()" or a task was aborted, the $ent->{response_packet} is guaranteed to be undef. If it is necessary to distinguish between the last two cases, the $ent->{status} may be examined for a string 'ABORTING' or 'FINISHED'. The code reference will be called with one argument, the $ent object. zone (optional) A zone specification (typically a DNS zone name - e.g. host, domain, or RBL) which may be used as a key to look up per-zone settings. No semantics on this parameter is imposed by this module. Currently used to fetch by-zone timeouts. timeout_initial (optional) An initial value of elapsed time for which we are willing to wait for a response (time in seconds, floating point value is allowed). When elapsed time since a query started exceeds the timeout value and there are no other queries to wait for, the query is aborted. The actual timeout value ranges from timeout_initial and gradually approaches timeout_min (see next parameter) as the number of already completed queries approaches the number of all queries started. If a caller does not explicitly provide this parameter or its value is undefined, a default initial timeout value is settable by a configuration variable rbl_timeout. If a value of the timeout_initial parameter is below timeout_min, the initial timeout is set to timeout_min. timeout_min (optional) A lower bound (in seconds) to which the actual timeout approaches as the number of queries completed approaches the number of all queries started. Defaults to 0.2 * timeout_initial. $obj is returned by this method. $obj = $async->get_lookup($key) Retrieve the pending-lookup object for the given key $key. If the lookup is complete, this will return "undef". Note that a lookup is still considered "pending" until "complete_lookups()" is called, even if it has been reported as complete via "set_response_packet()" or "report_id_complete()". @objs = $async->get_pending_lookups() Retrieve the lookup objects for all pending lookups. Note that a lookup is still considered "pending" until "complete_lookups()" is called, even if it has been reported as complete via "set_response_packet()" or "report_id_complete()". $async->log_lookups_timing() Log sorted timing for all completed lookups. $alldone = $async->complete_lookups() Perform a poll of the pending lookups, to see if any are completed; if they are, their <completed_callback> is called with the entry object for that lookup. If there are no lookups remaining, or if too long has elapsed since any results were returned, 1 is returned, otherwise 0. $async->abort_remaining_lookups() Abort any remaining lookups. $async->set_response_packet($id, $pkt, $key, $timestamp) Register a "response packet" for a given query. $id is the ID for the query, and must match the "id" supplied in "start_lookup()". $pkt is the packet object for the response. A parameter $key identifies an entry in a hash %{$self->{pending_lookups}} where the object which spawned this query can be found, and through which futher information about the query is accessible. If this was called, $pkt will be available in the "completed_callback" function as "$ent-<gt"{response_packet}>. One or the other of "set_response_packet()" or "report_id_complete()" should be called, but not both. $async->report_id_complete($id,$key,$key,$timestamp) Register that a query has completed, and is no longer "pending". $id is the ID for the query, and must match the "id" supplied in "start_lookup()". One or the other of "set_response_packet()" or "report_id_complete()" should be called, but not both. $time = $async->last_poll_responses_time() Get the time of the last call to "poll_responses()" (which is called from "complete_lookups()". If "poll_responses()" was never called or "abort_remaining_lookups()" has been called "last_poll_responses_time()" will return undef. perl v5.12.1 2010-03-16 Mail::SpamAssassin::AsyncLoop(3)
All times are GMT -4. The time now is 10:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy