Home
Man
Search
Today's Posts
Register

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

Login to Reply

 
Thread Tools Search this Thread
# 8  
Old 03-05-2013
Yes. I agree. I don't know what I was thinking!

Apologies.

Robin
# 9  
Old 03-05-2013
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.
# 10  
Old 03-06-2013
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 11:41 AM..
# 11  
Old 03-06-2013
Quote:
Originally Posted by Corona688
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

Regards,
Alister
# 12  
Old 03-06-2013
Quote:
Originally Posted by Corona688
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...
# 13  
Old 03-07-2013
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%
)

# 14  
Old 03-07-2013
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...
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove characters from the file expert Shell Programming and Scripting 9 05-08-2013 02:06 PM
Want to remove the last characters from each row of csv using shell script rajak.net Shell Programming and Scripting 24 12-15-2011 05:54 AM
Remove the characters from the file Kattoor Shell Programming and Scripting 6 02-16-2010 01:48 AM
How to remove Ctlr-M characters from file from a unix script akashtcs Shell Programming and Scripting 2 08-18-2009 05:11 AM
How to remove ^M characters from a zip file? bhaskar_m Shell Programming and Scripting 2 06-25-2009 08:01 AM
sed script to remove nth characters from end of filename Monkey Dean Shell Programming and Scripting 2 06-24-2009 02:39 AM
Remove characters from file name mrlayance Shell Programming and Scripting 5 04-28-2009 09:04 PM
SUPER simple bash script to repeat a command... robfindlay Shell Programming and Scripting 6 03-23-2009 05:12 PM
sed to remove last 2 characters of txt file ajp7701 Shell Programming and Scripting 1 10-29-2008 08:23 PM
Script to find and remove characters Zerby Shell Programming and Scripting 5 01-30-2008 02:16 AM


All times are GMT -4. The time now is 02:19 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password