Windows 10 Shortcut Target - Change Working Directory? - windows

I have this file structure:
Program_Folder
-> Program.exe
Data_Folder
-> Data1
-> Data2
-> Data3
etc.
Adding an absolute path to each data file works but I quickly run out of characters. The limit is 260 characters, I believe. Is it possible to change the working directory once and then add all the data files?
I'm also wondering if this can be done with a relative path. Something similar to the command line "cd.." "cd Data_Folder". Can this be done?
In the shortcut:
Target: C:\Program_Folder\Program.exe C:\Data_Folder\Data1 C:\Data_Folder\Data2 C:\Data_Folder\Data3

Since I'm getting dislikes instead of an answer I guess I will try and answer my own question.
What I ended up doing instead of a shortcut was a batch file. I put this file in the Data_Folder making this the working directory for the batch file. Then I made a shortcut to the batch file instead. This works but it feels a bit hacky. Anyone have a better solution?
C:\Program_Folder\Program.exe ^
Data1 ^
Data2 ^
Data3 ^

Related

Command prompt batch renaming results in syntax error

I need to rename 80k files in multiple folders & subfolders in the same directory. I have been trying to use ren but have been unsuccessful; I get an incorrect syntax error.
My old name looks like this:
c:/users/alice/BiDIR_DOCS_2017_Nov08020423\Company,LLC##NA##7967425.00##7967425.00\Company LLC A and A - Aug2017.pdf BiDIR_DOCS_2017_Nov08020423\Company, LLC##NA##7967425.00##7967425.00\document_# (x.y.z)-test~.pdf
and my new name looks like this:
c:/users/alice/BiDIR_DOCS_2017_Nov08020423\Company,LLC##NA##7967425.00##7967425.00\Company LLC A and A - Aug2017.pdf BiDIR_DOCS_2017_Nov08020423\Company, LLC##NA##7967425.00##7967425.00\system, a old name~ ` to # system b document (xyz)-test.pdf
I have the existing directory print in one column of Excel and in the next column what I want the directory print to be.
I'm not sure if I'm starting my ren command at the right hierarchy of my directory, or if I need quotation marks to keep the spaces and symbols in my new name.
I have tried improvising and testing on my own without success and I cannot find an article online on point.
Try FAR (find and replace) - it a free utility that works well.
http://findandreplace.sourceforge.net/

Change directory and executing external command in cmd - ERLANG

I am working on Erlang script that need to execute some command in cmd. I was trying to solve problem on this way, but I get nothing.
start() ->
comparing(0000).
comparing(Num) ->
file:set_cwd("F:\Documents\UPI\dump_rabbitmq\rabbitmq-dump-queue-v0.3-windows-amd64"),
DirOut = os:cmd("dir"),
io:format("DirOut=~p~n", [DirOut]),
os:cmd('rabbitmq-dump-queue -uri="amqp://username:password#localhost:5672/" -queue=try -full -max-messages=5 -output-dir=E:\Programs\Erlang\erl8.3\usr'),
NumMes = Num,
io:format("NumMes=~p~n", [NumMes]),
NameF = "msg-000",
io:format("NameF=~p~n", [NameF]),
FileName = concat(NameF, lists:flatten(io_lib:format("~p", [NumMes]))),
io:format("FileName=~p~n", [FileName]),
File = filelib:is_regular(FileName),
io:format("File=~p~n", [File]),
...
This is just a part of code where I have a problem. In line file:set_cwd("F:\Documents\UPI\dump_rabbitmq\rabbitmq-dump-queue-v0.3-windows-amd64") I want to change directory.
In this two lines I check if directory is changed:
DirOut = os:cmd("dir"),
io:format("DirOut=~p~n", [DirOut])
And in line os:cmd('rabbitmq-dump-queue -uri="amqp://username:password#localhost:5672/" -queue=try -full -max-messages=5 -output-dir=E:\Programs\Erlang\erl8.3\usr') I want to execute command in cmd for dump messages from RabbitMQ server. I was trying to change directory with os:cmd("cd F:\Documents\UPI\dump_rabbitmq\rabbitmq-dump-queue-v0.3-windows-amd64"), but nothing happends. Any suggestion how to solve this problem?
EDIT
Problem is solved. It's neccesary to have two slashes in this line: file:set_cwd("F:\\Documents\\UPI\\dump_rabbitmq\\rabbitmq-dump-queue-v0.3-windows-amd64") Dogbert solved the problem in comments.
There are two problems in the code:
You cannot change the working directory with os:cmd("cd ..."), you need to call file:set_cwd/1. os:cmd("cd ...") will only change the directory for the execution of that command, the change will not persist for future calls to os:cmd/1.
You need to escape the slashes, otherwise they're interpreted as escape sequence when it's a valid escape sequence, otherwise they're ignored.
1> io:format("~s~n~s~n", ["C:\abc\nop", "C:\\abc\\nop"]).
C:abc
op
C:\abc\nop
So, changing this:
os:cmd("cd F:\Documents\UPI\dump_rabbitmq\rabbitmq-dump-queue-v0.3-windows-amd64"),
to:
file:set_cwd("F:\\Documents\\UPI\\dump_rabbitmq\\rabbitmq-dump-queue-v0.3-windows-amd64"),
should fix your problem.

How can I find the particular file in a Project/Folder in Sublime Text

I know that using ctrl+shift+f we can find the text in folder we want and simple ctrl+f will find the text in a opened file or we can right folder and click on a option Find in Folder... to search the text
I am looking for, how can I find the file in a Folder/Project.
You can use the Goto Anything feature (Ctrl+P on Windows and Linux, Cmd+P on macOS) and type the name of the file you're looking for. If there are multiple hits, you can select the appropriate file using cursor keys. It also supports powerful operators, that let you jump to specific parts inside a file.
Examples:
file.js opens that file
:100 jumps to line 100 in current file
file.js:100 jumps to line 100 in file.js
#loadFile lists all files with classes/functions named loadFile (shortcut: Ctrl+R, Cmd+R on macOS)
file.js#loadFile jumps to a loadFile() in file.js
This can be done using:
Windows: Ctrl + P
Mac: Cmd + P
It works much like ItelliJ's Shift - 2 times, with a faster and accurate prediction.

Windows program files path names?

Maybe this can be a silly question but I don't figure out how to search in google why in some code I read, it is used to write this way: \\progra~1
What does ~ and 1 mean?
I tried executing in Windows Run the same path but changing numbers and these are the results:
C:\progra~1 -> Opens Program Files
C:\progra~2 -> Opens Program Files(x86)
C:\progra~3 -> Opens ProgramData
C:\progra~4 -> Opens ProgramDevices, a folder I created in C:\
Why? Is this like a Match or something in the Folder names list?
For example a regex like "progra" and then to show the ~1 (First) match in some X order or ~2 (Second) ... etc?
It's a compatability mode with the old (really old) windows 8.3 naming convention. The ~n represents the instance of the name that has the same root characters.
In your example:
Program Files and Program Files(x86) have the same root characters Progra.
Hence one gets progra~1, the next progra~2 etc.
8.3 compatability can be turned off for a disk partition.
Exactly, it's a pattern counter.
Check out also this answer: What does %~d0 mean in a Windows batch file?
You can find more examples of different variables with modifiers here:
https://technet.microsoft.com/en-us/library/bb490909.aspx
(ctrl-f for "Variable substitution")

Using a passed in parameter value to set PATH variables in a batch file

Right now I have a batch file that sets the PATH variable to all of the required directories.(there is actually a bunch more required directories, i just took them out so the code snippet would not be too long)
#echo off
set PATH=D:/src/trunk/build/bin;D:/src/trunk/build/bin/CoreTools;D:/src/trunk/build/bin/Plugins/Extensions;D:/src/trunk/build/bin/Plugins/CustomUI
set DEBRIEF_INSTALL_DIR=D:/src/trunk/DebriefSuite/D3D_Installation
set READERS=D:/src/trunk/build/bin/CoreTools/Readers
set BINARY_DIR=D:/src/trunk/build
cd D:/src/trunk/build/bin
start PROGRAM.exe --ConfigFile="D:/src/trunk/DebriefSuite/Installation/config/Projects/config.xml" ^
--Mode-File="D:/src/trunk/DebriefSuite/Installation/config/Projects/Common/anotherconfig.xml" ^
--Env:Bin="D:/src/trunk/build/bin"
cd D:/src/trunk
It works fine, but all of the directories are hard-coded. This needs to be able to work for other computers that might have their root directory in a different location. I need to be able to pass in a root directory (something like "D:\different_root_location") and substitute it in to each place in this code that currently says "D:\src\trunk". The problem is, i am not sure what the syntax would be for something like this. I am new to writing batch files. I tried doing something like
SET ROOTDIR=%1 .....
And then
set PATH=%ROOTDIR%/build/bin;%ROOTDIR%/build/bin/CoreTools;%ROOTDIR%/build/bin/Plugins/Extensions;%ROOTDIR%/build/bin/Plugins/CustomUI ..........
start PROGRAM.exe --ConfigFile="%ROOTDIR%/DebriefSuite/Installation/config/Projects/config.xml" ^
but it did not work. I'm not really sure how to make this work! Also, any links to good sources of information about writing batch files in general would be extremely helpful since i am starting out!
Change your line so it includes the original path as well.
From this:
set PATH=D:/src/trunk/build/bin...
to this: (and Windows uses \ and not / even though it works in some cases)
set PATH=%path%;D:\src\trunk\build\bin....

Resources