Windows Batch-File to JScript

After installing Leo's crop button, I found myself wanting more.

In my daily workflow, I also need to copy the cropped images and Wikipedia articles (downloaded as *.md) into various folders. As this is a very repetitive task, I created a batch file

cd F:\_download
copy *.jpg F:\data\obsidian\vault\multimedia\_images\person
copy *.md "F:\data\obsidian\vault\multimedia\crew\05 actor"
echo copied
move *.jpg F:\_download\_delete
move *.md F:\_download\_delete
echo moved

which, after some juggling, I managed to make accessible via a button :slight_smile: . Now the directory is clean except for the files to be moved; the batch file(s) are in their proper folder in my Obsidian vault. (Using Obsidian to build a movie reference)

NOW: Instead of the batch file, I want to use a JScript script, which I thought would be a simple feat, since there are basically only 2 commands involved (copy, move) ...

So I started to search for "learn JScript". Here, in the Opus-Forum I found β€œthis awesome post" and believed myself happy until I started to actually look up the links - far above my paygrade.

Well, so I googled and β€œyoutubed” for JScript, JScript tutorials, and found two meager YT-videos about compiling JScript and a ton (TON) of videos and tutorials on JavaScript...

JScript and JavaScript are supposed to be two different languages with similarities, I thought, but now I read in the Wikipedia article on JScript, they’re not really, just a name change by Microsoft to avoid copyright issues.

Honestly, I only want to copy a few files...

Finally I found this β€œCopyFile Method” which seems to be a start, but I'm so insecure now that I don't want to try it alone. I don't even know how to start yet.

Please help!

No need for a batch or script, a simple command button is all you need:

Copy      FILE=F:\_download\*.jpg   TO="F:\data\obsidian\vault\multimedia\_images\person"
Copy      FILE=F:\_download\*.md    TO="F:\data\obsidian\vault\multimedia\crew\05 actor"

Copy MOVE FILE=F:\_download\*.jpg   TO=F:\_download\_delete
Copy MOVE FILE=F:\_download\*.md    TO=F:\_download\_delete

(" are mandatory for paths that contain spaces, otherwise optional.)


1 Like

Thank you very much. Works like a charm. And I learned something new :smiley:

Where do I learn using JScript?
Is there a noteworthy difference between JScript and JavaScript?

Thanks again!

JScript is Microsoft's version of JavaScript. Quite old by now, unfortunately, but sufficient for Opus scripts. To learn, just grab stuff you like from the forum, modify it until it breaks, then fix it again. You'll find many JavaScript resources on the web to look up details like correct syntax.

Get an editor that has JavaScript language support and code formatting. I mostly use VS Code and Notepad++.

Also available via winget:

winget install --id Microsoft.VisualStudioCode
winget install --id Notepad++.Notepad++

...however debugging is a pain. At least if you are using DO exclusive objects...

Thank you! As I need to do a lot of textmanipulation (regex) I already have VSCode, SublimeText, Brackets, notepad++ installed. But if I understand you correctly there is no single point to start with JScript. I simply continue with the excellent courses on and hope for the best...

Thanks a lot for your help :smiley: