Prompts and Ajax calls?

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Prompts and Ajax calls?

Postby hmt3design » Fri Mar 31, 2017 7:39 pm

I'm working on a renaming script and I want to prompt for sequence beginning numbers and pads. Can I use the JS "prompt" command?
Also, do I need to do an Ajax call in order to get the number of files in a directory?

What I have so far:

'use strict';

var prefix = prompt('Prefix:');
var beginSeq = prompt('Begin center sequence #:');
var beginPadAmount = prompt('Number to pad center sequence:');
var suffixSeq = prompt('Begin suffix sequence #:');
var suffixPadAmount = prompt('Number to pad suffix sequence:');
var suffixTopAmount = prompt('Max number for suffix:')


function beginPad(beginSeq, beginPadAmount) {
var beginPadString = '' + beginSeq;
while (beginPadString.length < beginPadAmount) {
beginPadString = '0' + beginPadString;
}
return beginPadString
}

function suffixPad(suffixSeq, suffixPadAmount) {
var suffixPadString = '' + suffixSeq;
while (suffixPadString.length < suffixPadAmount) {
suffixPadString = '0' + suffixPadString;
}
return suffixPadString
}



console.log(prefix + '-' + (beginPad(beginSeq, beginPadAmount)) + '-' + (suffixPad(suffixSeq, suffixPadAmount)));
hmt3design
 
Posts: 1
Joined: Fri Mar 31, 2017 7:22 pm

Return to Javascript Renaming


cron