Main > Everything Else

IT gurus - need your advice please!

(1/1)

MrThunderwing:
Howdy all,

I need a bit of advice with a batch file conundrum I'm having, I was wondering if one of you more tech savvy geniuses might be able to help, please?

I'm not super coding savvy, but I've picked up a few bits here and there from various gaming forums and the like.

I've tried to use this to streamline one aspect of my regular work life by writing a batch file to open all the folder I need to use in the day in one single click, rather than manually opening each one, and also the programs I need too, usually a word document and 2 excel files. I can open up the folders no problem. I can open a file with no issue if there's no space in the name i.e


--- Code: ---start /D "M:\Documents\Alex" excel.exe Calculations.xlsx
start /D "C:\Users\OneDrive\Documents" CR-APC.docx
--- End code ---

But if the file has a space in its name, so for example, the Excel document is called something like "Weekly Name List 2024.xlsx" or the Word document is "Weekly Priorities.docx" the batch file throws up an error. I've tried to Google a solution, but I can't find anything that seems to specifically cover this issue, the answers to the no-spaces-in-batch-files answers all seem a bit above my level of comprehension, with lots of extra stuff I don't have a clue about. I've been able to just rename some of the files to just get rid of the spaces, but some of these are shared documents so I can't do that with them.

Does anyone know how I can alter the batch files to read the Excel and Word douments with spaces in them?

Thanks!


thebyter:
You need to put the filenames in double quotes (..."My File.txt").  However, when START sees bare double quotes, it uses that string as the window title:


--- Code: ---C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
      [/MACHINE <x86|amd64|arm|arm64>][command/program] [parameters]

    "title"     Title to display in window title bar.
    ...
--- End code ---

So you need to provide a window title, even a fake or empty one:


--- Code: ---start "" /D "M:\Documents\Alex" excel.exe "June Calculations.xlsx"
--- End code ---

Thanks!
The Byter

MrThunderwing:
Nice one dude. I'll give that a try when I'm back in tomorrow, cheers

Navigation

[0] Message Index

Go to full version