Creating a shortcut for a file using MATLAB - file

I would like to create a shortcut to an existing image file using MATLAB routines. My goal is to have a shortcut in a folder that i specify, to the image from another folder that i specify (for organizing purposes).
What i want to achieve is the same thing that happens when i right click on the image icon and select 'create shortcut' option, only changing the target directory for the created shortcut.
I have about twenty thousand images to orginize so copying the files instead is not an option(it takes a really long time).
I will really appreciate any help. Thank you!

Why don't you try to add the path (addpath) and then use directly Matlab behaves as if the images are in the same folder. Check here

You could call a VBS script from MATLAB.
For VBS script see: http://technet.microsoft.com/en-us/library/ee156583.aspx
Then write a wrapper function in MATLAB calling the VBS script with a system command:
cmd=sprintf('cscript //nologo "%s" %s "%s" "%s" "%s" "%s" "%s"',...
vbsfile,name,targetpath,workingdir,iconlocation,hotkey,desc);
system(cmd);

Related

Is it possible to embed an executable inside a batch file?

There are many programs which help me write more efficient code (NirCmd etc.), but they can't run properly if they aren't installed in the computer. So is there a way to, for example, in the temp folder, extract the program from a batch program and use it.
I tried reading the executables with a hex editor, putting the hex code into another file and saving it as an executable. But this failed. So, is there any way to efficiently store an executable inside a batch file, create it and then run it?
Yes, there is one that I know of and works perfectly.
It is a program called bhx.exe (link to its site here).
It can also embed other file types.
The usage is quite simple:
(optional) Create a cabinet (.cab) file from the original .exe using this command: makecab yourexe.exe yourexe.cab. For better compression you can use the /D switch in this way: makecab /D CompressionType=LZX yourexe.exe yourexe.cab
CD to the directory bhx is in and do this: bhx yourexe.cab. Other switches are described in the website.
There you go, the mybin.cmd file is generated.

Write a batch script to edit text in a .cs file

I wonder if anyone knows how to write a batch script to edit some text in a .cs file.
What I want to do is change "AssemblyVersion("1.0.0.0")" "AssemblyVersion("1.0.0.x")" where x++ for every time the job in jenkins is being built.
Best Regards Jan
Do you want to use only a batch script for this? You could also use Execute Groovy Script option and write some simple groovy script to achieve this
file = new File("folder/path/myfile.cs")
fileText = file.text;
fileText = fileText.replaceAll(srcExp, replaceText);
file.write(fileText);
You can also use the availabe environment variables from your jenkins job to construct your replace text. These variables will be present at /env-vars.html
Stay away from "batch-file automation" - will only cause you grief.
(for a starter, different versions of Windows support a different set of batch-commands)
You should incorporate the build-number in the script as an Environment Variable -
use either the "built-in" %BUILD_NUMBER% parameter or set your own format with
the Formatted Version-Number Plugin .
If you do need to edit that 'CS' file, I suggest using either Perl or PowerShell.
Cheers

Using a .bat file for integration to client

I was trying to put together a .bat file program that presents readable information. Basically, we have a application called vSphere that reads custom scripts directly from a xml file. So there are xml elements that are passed into the the client. Now, I have a similar situation where we are doing the same thing with vCloud. The difference is that vCloud only reads data from a .bat file instead of a xml file.. If I wanted to do such a thing what would that look like.. Below is my psuedo code as I'm not completely familiar with .bat file syntax. Is this how I can present the information to be read by the vCloud client? The client already knows how to read the .bat file, I just need help with a control structure example of a .bat file to tackle this problem.
xml version:
<_type>viss.CustomizationExample</_type>
<changeExample>1341932956</changeExample>
.bat file version:
#echo off
SET ChangeExample=1341932956
if changeExample==""(
echo changeExample==ChangeExample
)
Thank you!
this code may work for you
#echo off
set changeExample=1341932956
echo %changeExample%
This will display the value of changeExample 1341932956 on the cmd screen if you run the batch file is this what you wanted...
Your almost there, just a couple of things.
To access a variable after setting it, without any special circumstances, you need to put %'s at each side of it to tell cmd that you want the value contained in it.
By default if is case sensitive, so you must first make sure that your variables are spelt
correctly, also you need a space between the end of the if condition and the bracket.
Provided that this is the correct format for the batch (I don't have a clue what it actually wants to read) then this is the correct syntax
#echo off
SET ChangeExample=1341932956
if %ChangeExample%=="" (
echo changeExample==%ChangeExample%
)
I presumed you wanted to echo the variable contents rather than the string ChangeExample, if you just want the string remove the %'s.

Combining files in Notepad++

Is there a Notepad++ plugin out there that automatically combines all currently opened files into a single file?
Update: Yes, I am very aware of copy and paste :) I'm working with lots of files, and I want a solution that makes this step in the process a little bit faster than several dozen copy and pastes.
I'm aware of utilities for combining files, but I want the convenience of combining specifically the files that are currently opened in my text editor.
If there isn't a plugin out there already, I'll write one myself; I was just wondering if it exists already to save me the time of developing one.
I used the following command in DOS prompt to do the merge for me:
for %f in (*.txt) do type "%f" >> output.txt
It is fast and it works. Just ensure that all the files to be merge are in the same directory from where you execute this command.
http://www.scout-soft.com/combine/
Not my app, but this plug in lets you combine all open tabs into one file.
I installed the Python Script plugin and wrote a simple script:
console.show()
console.clear()
files = notepad.getFiles()
notepad.new()
newfile = notepad.getCurrentFilename()
for i in range(len(files) - 1):
console.write("Copying text from %s\n" % files[i][0])
notepad.activateFile(files[i][0])
text = editor.getText()
notepad.activateFile(newfile)
editor.appendText(text)
editor.appendText("\n")
console.write("Combine Files operation complete.")
It looks at all the files currently opened in Notepad++ and adds them to a new file. Does exactly what I need.

Creating a batch file to do drag and drop files onto an exe

I have an exe that I can drag and drop another file onto to produce a third file. Unfortunately it seems to accept only 1 file at a time, if I select multiple and drop it doesn't seem to work.
How do I create a batch file to automate the process of dragging a thousand files of .drag extension onto drop.exe?
Thanks!
In Windows, dropping a file on an exe just executes the command line:
fileprocessor.exe "<full path to dropped file>"
So you should be able to just call the exe directly in your batch file, passing the path to each file that you'd like to process.
EDIT: Look into the For batch command to do this for a series of files. You should be able to specify the wildcard and then call the command for each.
For %%a in (*.drag) do fileprocessor.exe "%%~fa"
Evidently, batch files can have multiple objects dropped onto them. See this question. You should be able to adapt the answer to your needs. I do wonder if there is a maximum number of characters that can be passed in, though, so you might not be able to drag thousands of files onto it. Possibly not even hundreds. But definitely multiple.
EDIT: In your comment to dmercredi's answer, you mention wildcards. If you don't need the drag/drop capability and just want to specify *.drag in your batch file, check out this question instead. There are a variety of answers there that may suit your needs.

Resources