[SOLVED] Is this even possiable?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
llabtaem
Posts: 3
Joined: 31 Dec 2012 13:38

[SOLVED] Is this even possiable?

#1 Post by llabtaem » 31 Dec 2012 13:55

I am trying to make a batch file open up a specific file(s). This is what I am trying to do. You run the batch file select your option (which in this case is one) and it will open up this file with the appropriate program, so this program can convert this file into the appropriate format. Here is the code, highlighted in red is the part of the code that doesn't work.

    @ECHO off
    cls
    :start %1
    ECHO.
    ECHO 1. Convert Libary Books
    ECHO.
    ECHO 2. Move books from Downloads to Libary
    ECHO.
    ECHO 3. Sync Device to Libary
    ECHO.
    set choice=
    set /p choice=What would you like to do today? (Press 1, 2 or 3)...
    if not '%choice%'=='' set choice=%choice:~0,1%
    if '%choice%'=='1' goto convert
    if '%choice%'=='2' goto move
    if '%choice%'=='3' goto sync
    ECHO "%choice%" is not valid, try again
    ECHO.
    goto start
    :convert
    "C:\Program Files (x86)\Adobe\Adobe Digital Editions 2.0\DigitalEditions.exe" "C:\Users\%username%\Downloads\*.acsm"
    goto end
    :move
    move "C:\Users\%username%\Downloads\*.epub" "C:\Users\%username%\My Documents\My Libary"
    goto end
    :sync
    copy "C:\Users\%username%\My Documents\My Libary\*.epub" "j:\database\media"
    goto end
    :end

Everything else works fine (obviously, nothing but moving and copying). I can get the program to open up just fine but, it won't load the file(s). The reason for this is Barnes & Nobles doesn't make a user friendly program for people that aren't very tech savvy like my mother which this project is for. I tried this program called " Calibre " but, that program is terrible. Any help is greatly appreciated. Thank you for your time.
Last edited by llabtaem on 02 Jan 2013 13:52, edited 1 time in total.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Is this even possiable?

#2 Post by Squashman » 31 Dec 2012 14:16

Your executable would have to allow arguments to be passed to it for that too work. I would look at the help to see if you need a switch before the file you want to open.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Is this even possiable?

#3 Post by abc0502 » 31 Dec 2012 14:19

Does this application "DigitalEditions.exe" support converting from the command line ?

But i suspect that it is because of using the wild card to give files name.
using a for loop to acquire the files names should work if it was that case:

Code: Select all

Setlocal EnableDelayedExpansion
For /F "delims=" %%A in ('DIR /B /A:-D "C:\Users\%username%\Downloads\*.acsm"') Do (
    "C:\Program Files (x86)\Adobe\Adobe Digital Editions 2.0\DigitalEditions.exe" "C:\Users\%username%\Downloads\%%~nA.acsm"
    )

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Is this even possiable?

#4 Post by Squashman » 31 Dec 2012 14:35

When you install Adobe Digital Editions it does create a file association with acsm file types.

So in theory you could attempt to just do this.

Code: Select all

For /F "delims=" %%A in ('DIR /B /A:-D "C:\Users\%username%\Downloads\*.acsm"') Do start "" "C:\Users\%username%\Downloads\%%~A"

llabtaem
Posts: 3
Joined: 31 Dec 2012 13:38

Re: Is this even possiable?

#5 Post by llabtaem » 01 Jan 2013 07:33

@ Squashman, yes Adobe Digital Editions owns the file format. It stands for Adobe Content Server Message (acsm). The code you gave me works but it only opens up one file. Once in a while it will covert all files.

@ abc0502, I don't know if this program supports command line input but, the code you gave me does work but, I have to close the program so it can convert another file, so I am assuming yes?

Obviously I am new to batch so I don't know how to tweak the lines of code you both gave me to open up one instance of the program and covert all the files. I will look around on the internet some more to see where I need to tweak the lines of code. Thank you both for your time, you both really helped out a lot.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Is this even possiable?

#6 Post by Squashman » 01 Jan 2013 11:22

The only way you are going to get it too work the way you want is if the software supports some kind of batch mode which it doesn't sound like it does. My command would in theory open an instance of Digital Editions for every ACSM file you have in that folder. Your software may not like that which is why it may not be converting all of them. There doesn't seem to be a native switch to allow you to use the software in an automated mode to process all the files and close. From what I read online you need to use Adobe's SDK to do that.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Is this even possiable?

#7 Post by abc0502 » 01 Jan 2013 19:03

@ abc0502, I don't know if this program supports command line input but, the code you gave me does work but, I have to close the program so it can convert another file, so I am assuming yes?

Well. If it works and you need to close the program to convert another file just add this command:

Code: Select all

Taskkill /F /IM:"DigitalEditions.exe" 2>nul

I'm here assuming that "DigitalEditions.exe" is the process name that appear in the task manager while the application is running.

So the code should be like this:

Code: Select all

Setlocal EnableDelayedExpansion
For /F "delims=" %%A in ('DIR /B /A:-D "C:\Users\%username%\Downloads\*.acsm"') Do (
    "C:\Program Files (x86)\Adobe\Adobe Digital Editions 2.0\DigitalEditions.exe" "C:\Users\%username%\Downloads\%%~nA.acsm"
    Taskkill /F /IM:"DigitalEditions.exe" 2>nul
    )

and as Squashman said, you should try the SDK as this solution won't be that good, it just a work around for the current problem.
you can try this command in the CMD to see if there is a help document for that exe:

Code: Select all

"C:\Program Files (x86)\Adobe\Adobe Digital Editions 2.0\DigitalEditions.exe" -help
or

Code: Select all

"C:\Program Files (x86)\Adobe\Adobe Digital Editions 2.0\DigitalEditions.exe" --help
or

Code: Select all

"C:\Program Files (x86)\Adobe\Adobe Digital Editions 2.0\DigitalEditions.exe" /?

if it has, one of these should work and if it does, post the help documents here.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Is this even possiable?

#8 Post by foxidrive » 02 Jan 2013 02:40

You will have to use a delay before taskkill ing the application.
It's not elegant but it will work - it depends on around how long each task takes to complete.

This will wait around 10 minutes (600 seconds) before killing the task and starting the next task (untested):

Code: Select all

@echo off
  For /F "delims=" %%A in ('DIR /B /A:-D "C:\Users\%username%\Downloads\*.acsm"') Do (
    start ""  "C:\Program Files (x86)\Adobe\Adobe Digital Editions 2.0\DigitalEditions.exe" "C:\Users\%username%\Downloads\%%~nA.acsm"
    ping -n 600 localhost >nul
    Taskkill /F /IM:"DigitalEditions.exe" 2>nul
  )

miskox
Posts: 669
Joined: 28 Jun 2010 03:46

Re: Is this even possiable?

#9 Post by miskox » 02 Jan 2013 12:33

Google search reveals that .acsm files are tokens which enable users to download Digital Edition ebooks.

Hope this helps.

Saso

llabtaem
Posts: 3
Joined: 31 Dec 2012 13:38

Re: Is this even possiable?

#10 Post by llabtaem » 02 Jan 2013 13:51

@ abc0502, I tried the code you provided but, unfortunately I still have to close the program manually but, it does work with foxidrive added line of code. As for the help documents there were none but, I clicked on the help button in the program and it took me to this link (Adobe's Digital Editions FAQ) so I don't know if that is what you are looking for or if it helps any.

@ foxidrive, the line of code you provided worked like a charm I brought it down to 10 seconds which is more than plenty of time. It converts the one file and about three seconds later it closes than it opens up again and converts the next file and after three seconds it closes.

I want to thank you all very very much for your time and help, hopefully one day I can contribute back. Now my mother should be all set. If she has trouble pressing three buttons I'm in trouble ha ha ha.

Post Reply