Unix/Linux Go Back    


Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

Super Simple Script to remove first characters of any png file

Windows & DOS: Issues & Discussions


Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 03-05-2013
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 20 October 2017, 11:53 AM EDT
Location: Lancashire, UK
Posts: 3,307
Thanks: 1,417
Thanked 648 Times in 584 Posts
Yes. I agree. I don't know what I was thinking!

Apologies.

Robin
Sponsored Links
    #9  
Old Unix and Linux 03-05-2013
pasc pasc is offline
Registered User
 
Join Date: May 2011
Last Activity: 14 June 2017, 7:09 AM EDT
Posts: 140
Thanks: 26
Thanked 1 Time in 1 Post
well. I'd love to do this without anything added besides the general DOS Shell.

I'd probably even cope with commands longer than 2 lines if needed.
Sponsored Links
    #10  
Old Unix and Linux 03-06-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 20 October 2017, 3:09 PM EDT
Location: Saskatchewan
Posts: 22,469
Thanks: 1,143
Thanked 4,262 Times in 3,936 Posts
Step 1: Install DOS. (You don't get that anymore, just Windows CMD.)

If CMD will do:


Code:
for %a in (*.png) DO ( set V=%a
echo rename %%V%% %%V:~2%% )

You can't do it in one statement because %a is not a 'real' variable, windows for is a strange beast.

Remove the echo once you've tested and are sure it does what you want.

Windows CMD is inconsistent here in that more %'s are required when you put this in a batch file than when you run it in a shell window; cmd's 'for' is a very strange beast. Some experimentation may be required.

Last edited by Corona688; 03-06-2013 at 10:41 AM..
    #11  
Old Unix and Linux 03-06-2013
alister alister is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 976 Times in 790 Posts
Quote:
Originally Posted by Corona688 View Post
I'd try this in a busybox shell:


Code:
( dd bs=2 count=1 > JUNK ; cat ) < $FILE > new-$FILE

dd's skip obviates both cat and the subshell. Therefore, it is with a heavy heart that I must award you this useless use of cat award Linux

Regards,
Alister
Sponsored Links
    #12  
Old Unix and Linux 03-06-2013
pasc pasc is offline
Registered User
 
Join Date: May 2011
Last Activity: 14 June 2017, 7:09 AM EDT
Posts: 140
Thanks: 26
Thanked 1 Time in 1 Post
Quote:
Originally Posted by Corona688 View Post
Step 1: Install DOS. (You don't get that anymore, just Windows CMD.)

If CMD will do:


Code:
for %a in (*.png) DO ( set V=%a
echo rename %%V%% %%V:~2%% )

.
Doesn't seem to work... neither directly in CMD nor in a bat file.

Like I said I want to achieve this without installing anything else...
Sponsored Links
    #13  
Old Unix and Linux 03-07-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 20 October 2017, 3:09 PM EDT
Location: Saskatchewan
Posts: 22,469
Thanks: 1,143
Thanked 4,262 Times in 3,936 Posts
To repeat:

Quote:
Originally Posted by Corona688
Windows CMD is inconsistent here in that more %'s are required when you put this in a batch file than when you run it in a shell window; cmd's 'for' is a very strange beast. Some experimentation may be required.
I tried to make it so it would work in a batch file, but didn't get the right combination I guess. This exact code works when typed into shell:


Code:
for %a in (*.txt) DO (
        set V=%a
        echo rename %V% %V:~2%
)

Sponsored Links
    #14  
Old Unix and Linux 03-07-2013
pasc pasc is offline
Registered User
 
Join Date: May 2011
Last Activity: 14 June 2017, 7:09 AM EDT
Posts: 140
Thanks: 26
Thanked 1 Time in 1 Post
Nope that doesn't work in DOS either.

I put a test.png in a folder.

1st try:
paste script in batch, execute -> Fail, png stays unrenamed

2nd try:
execute said script from CMD: -> Fail, output: "a cannot be syntactically processed here."

3rd try:
execute by pasting into command line -> see 1





Honestly I would be happy with ONLY ONE approach that will work while executed form a batch script...
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cgi script to print all .png files on a single page jeffersno1 Shell Programming and Scripting 3 06-07-2010 02:35 AM
Remove the characters from the file Kattoor Shell Programming and Scripting 6 02-16-2010 12:48 AM
How to remove Ctlr-M characters from file from a unix script akashtcs Shell Programming and Scripting 2 08-18-2009 04:11 AM
SUPER simple bash script to repeat a command... robfindlay Shell Programming and Scripting 6 03-23-2009 04:12 PM
Script to find and remove characters Zerby Shell Programming and Scripting 5 01-30-2008 01:16 AM



All times are GMT -4. The time now is 12:49 AM.