Windows Legacy OS forum

General discussion

(Hopefully) Simple Windows Batch Script

by mlacy03 / June 4, 2008 3:55 PM PDT

I'm trying to develop a batch script for getting photos off of an attached media card, into a directory in numerical order, with the directory being the current date. Each file would have that date and a three digit number (/6-7-08/6-7-08 000.jpg).

The only reason I am keeping it as a batch script is because it needs to be able to run with one file, one click and no installation. I'm a little out of my element (I tried writing a batch script in PHP syntax, it didn't work too well).

If you need anything else, let me know and I'll send it your way. Thanks in advance!

Discussion is locked
You are posting a reply to: (Hopefully) Simple Windows Batch Script
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: (Hopefully) Simple Windows Batch Script
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
This may help.
by MarkFlax Forum moderator / June 4, 2008 8:23 PM PDT
Collapse -
I've seen recommendations for this before, but...
by mlacy03 / June 5, 2008 5:14 AM PDT
In reply to: This may help.

I'm looking for strictly a batch file or VBScript solution, since the computer I'll be using this on is XP with very limited permissions (I have already checked, and I can run batch scripts and play around with the command prompt. I haven't touched those permissions, I guess).

Collapse -
Up your permissions.
by R. Proffitt Forum moderator / June 5, 2008 5:44 AM PDT

It's a PC so look up NTPASSWD to login as the ADMIN and fix it.

Collapse -
wsf javascript solution
by ramarc / June 5, 2008 6:09 AM PDT

<script language='jscript'>
function err( msg )
WScript.echo( msg );
Number.prototype.pad = function( n )
return ('0000000000000'+ this).slice( 0 - Math.abs(n) );

var BS = '\\'; // javascript use \ as escape char so it needs to be doubled
var from = WScript.Arguments.Named('from');
if (!from) from = 'E:'+BS; // set the default location as you see fit
var to = WScript.Arguments.Named('to');
if (!to)
var d = new Date();
to = [(d.getMonth()+1).pad(2),d.getDay().pad(2),(d.getYear() % 100).pad(2)].join('-');

var fso = new ActiveXObject('Scripting.FileSystemObject');

if (!fso.FolderExists(from)) err( 'From folder not found - '+ from );
var fromFolder = fso.GetFolder(from);
var toFolder;
if (fso.FolderExists(to))
toFolder = fso.GetFolder(to);
toFolder = fso.CreateFolder(to);
WScript.echo( 'Copying from '+ fromFolder.Path + '\n\tto '+ toFolder.Path );

var n = 0;
for (var e = new Enumerator(fromFolder.files); !e.atEnd(); e.moveNext())
var file = e.item();
var type = '.'+ file.Name.split('.').pop().toLowerCase();
if ('.jpg,.gif,'.indexOf(type+',') < 0) continue; // only process pictures
var s = n.pad(4); // format n with leading zeros
s = toFolder.Path + BS + to + ' '+ s + type; // s is now the destination path and name
WScript.echo( file.Name + ' -> '+ s );
file.Copy( s, true ); // this will overwrite any existing files


usage: getfiles /from:"e:\photos"
remember to set the cscript host beforehand: cscript //H:Cscript

Collapse -
Renamer can easily be used from the command line ...
by Edward ODaniel / June 5, 2008 6:20 AM PDT

and thus you can set it up as desired then save the rules as as preset and you have your "one-click" batch file running.

Download it and take a look at its User Manual.

Popular Forums
Computer Newbies 10,686 discussions
Computer Help 54,365 discussions
Laptops 21,181 discussions
Networking & Wireless 16,313 discussions
Phones 17,137 discussions
Security 31,287 discussions
TVs & Home Theaters 22,101 discussions
Windows 7 8,164 discussions
Windows 10 2,657 discussions


Help, my PC with Windows 10 won't shut down properly

Since upgrading to Windows 10 my computer won't shut down properly. I use the menu button shutdown and the screen goes blank, but the system does not fully shut down. The only way to get it to shut down is to hold the physical power button down till it shuts down. Any suggestions?