LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-18-2022, 08:29 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
How to copy in rename/ren tool's control ability


How do we or what tool to copy just in rename or ren utility control ability, simply do such but the source keep untouched ?
 
Old 10-18-2022, 10:29 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,198

Rep: Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307
Your English is terrible, but if you're asking what I think you're asking, then use "mv". If you're not using it across filesystems, then it only changes the directory entry. The file's disk blocks are untouched.

Last edited by dugan; 10-18-2022 at 10:31 PM.
 
1 members found this post helpful.
Old 10-18-2022, 11:20 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,258
Blog Entries: 3

Rep: Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713
I can't think of a way to copy and rename in one step. Perhaps others can.

If you don't have any commas in the file names, you could try parsing the output of rename into a file and then running that file as a script. The rename utility can use multile Perl expressions, so here are two. One is to do the renaming of the file, the other is to modify the directory. Adjust as needed. Perl is used to modify the output instead of sed because there is no equivalent to non-greedy matching in sed:

Code:
rename -n -v 's/old/new/; s|^|/path/to/destination/|;' * \
    | perl -p -e 's/^.*?\(/cp -p /; s/, / /; s/\)$//;' \
    > ren

nano ren

. ren
Otherwise, you'll probably have to just manually enumerate the files into a script and then edit that script by hand to do what you want.
 
Old 10-18-2022, 11:37 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,258
Blog Entries: 24

Rep: Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193
Quote:
Originally Posted by Turbocapitalist View Post
Otherwise, you'll probably have to just manually enumerate the files into a script and then edit that script by hand to do what you want.
I agree with this! I have wasted more time trying to figure out how to copy/move and rename groups of files with a single command than it usually takes to list them into a file, use a few (safe) regular expressions or manual edits to translate those into commands then execute the file, possibly after testing an example manually.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to run Ren'Py on Ubuntu? LXer Syndicated Linux News 0 07-30-2019 02:40 PM
LXer: Ren'Py, One of the Best Visual Novel Engines! LXer Syndicated Linux News 0 07-25-2019 03:43 PM
LXer: Comparing Twine and Ren'Py for creating interactive fiction LXer Syndicated Linux News 0 07-04-2018 03:23 PM
LXer: No major coding experience required: Gaming and more with Ren&#039;Py LXer Syndicated Linux News 0 08-26-2013 08:21 AM
daemon dies, is restarted. Wants to reclaim previously running child(ren) tom_mee Linux - General 4 02-21-2012 07:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration