Can Anyone help with Scripting for Autohotkey to work with Handbrake? - scripting

I'm trying to make an autohotkey script so I can drag and drop movie files into autohotkey for it to put it into handbrake's queue to be converted into iphone format.
I just started with autohotkey and have no idea on how to record a macro like that. Can anyone point me the right way or maybe does anyone have a script like that to share?

Handbrake comes with a Command Line program (default path = C:\Program Files\HandBrake\HandBrakeCLI.exe)
That would probably be your best bet versus trying to make a macro to interact with the GUI version of Handbrake. If you only wanted to do one at a time a simple DOS batch script would allow you to drag and drop files:
1) Open Notepad
2) Paste the following text:
"C:\Program Files\HandBrake\HandBrakeCLI.exe" -i %1 -o %1.mp4 -e x264 -b 2000 -B 128 -X 480
3) Save the file as HandbrakeCLI.bat (or anything else you want as long as it ends in .bat)
4) Place that where the video you want to convert is located and drag the video file onto the .bat file. A DOS window should pop up and start converting the video.

Related

Grep the last lines of ouput

When running a shell command without redirection, I sometimes in hindsight want to process the output I see on screen.
I often want to "grep" the output of a console in hindsight. I might not be able to run the command again with proper redirection: (The command might take a long time to run. The command might have produced side effects).
Is there some shell wizardry which I could use to: "Grep the last 100 lines of output in the terminal", without re-executing the command again with a redirect?
My current solution is to scroll up manually, and copy paste the last lines of output into a text file. I would prefer a fully scripted solution instead...
Is there some shell wizardry which I could use to: "Grep the last 100 lines of output in the terminal", without re-executing the command again with a redirect?
No.
My current solution is to scroll up manually, and copy paste the last lines of output into a text file. I would prefer a fully scripted solution instead...
Exactly, you have to use the program that is used to view the output, be it a graphical terminal in a graphical environment. Some such terminals allow to save the current "state" of terminal output to a file. Next time - use tmux or screen - i.e. a program that simulates the terminal.

Downloading partial data from Kaggle

I am working on a project that identifies chess positions. The main database I found is on Kaggle however is it's size is 2 GB. Does anyone know if I can download only a small portion of the set instead of the entire thing?
link: https://www.kaggle.com/koryakinp/chess-positions
One way you can do it by clicking on the file one by one and click the download button on the top right of the file.
One more way you can do it download everything and delete the files you dont want.
Or you can use wget in command prompt or curl in terminal and use --max-filesize to limit it to the amount of bites you want.

Photoshop: Script to convert jpeg to 16 bit on open

Using Photoshop, I want to automatically convert all opened JPEGs to 16 bit. I currently do this manually before making any edits to them, and I figure I should be able to automate this step so it happens automatically.
I've learnt that I can run scripts on events using Scripts Event Manager, so I know how to run a script on document open.
But unfortunately I don't know how to write the Photoshop script itself.
Can anyone assist with how I'd write a script that detects whether the current document is RGB/8bit, and if it is, converts it to RGB/16bit, automatically on document open?
Alternatively, if there's any easier way to do this using Actions or something, that'd be good to know.
After deciding to not be lazy and look into it myself... it turns out it is not difficult.
This script will convert the active document to 16bit if it ends in *.jpg or *.jpeg, is an RGB document, and is 8 bit.
Changing these if conditions is easy as you can see below.
Save it as a .js or .jsx file.
Then to run this script automatically on file open, use File → Scripts → Script Events Manager and choose Open Document as the Photoshop Event, then select or browse for your script.
if(
/jp.?g$/i.test(activeDocument.name)
&& activeDocument.mode == DocumentMode.RGB
&& activeDocument.bitsPerChannel == BitsPerChannelType.EIGHT
) {
activeDocument.bitsPerChannel = BitsPerChannelType.SIXTEEN;
}

Use photoshop in command window hiddenly

Is there a way to use Photoshop to convert image from command line.
for example :
Photoshop.exe -convert c:/img1.tif c:/img1.png
I want to run this command from command line, without opening Photoshop application.
I don't want to see Photoshop window.
Photoshop.exe -convert c:/img1.tif c:/img1.png
Won't actually do anything. Photoshop Scripts work in three flavours; Visual Basic, JavaScript and Applescript. There are no commands to "convert" between file types. You can write a script to save a .tiff to a .png BUT it will involve opening the Photoshop application.
I think you're actually after imageMagick - which can do conversions like the one above.
You can use ImageMagick, which is available for Windows from here. The command you want is convert like this:
convert c:\img1.tif c:\img1.png

How do I keep formatting when copying from gedit into open office?

I am editing octave files in gedit, and it does a nice job highlighting them. However, when I try to copy and paste the code into Open Office, it loses all formatting. Even when I try paste > special, it still doesn't work.
Is there any way to do this without having to manually go through all my code highlighting keywords?
The free and open source editor KATE can actually export in HTML Octave's code keeping the correct syntax highlighting.
I had the same problem and I found this very usefull page: http://tohtml.com/
So you don't need to install any other editor or stuff, just copy paste to the page and let it do it.
PS: It seems like the owner likes to sell the domain, so hopefully the project will stay online, otherwise you will find other solutions google: "cpp online syntaxhighlighter"
I don't know if this can be any good, but if you open the script with the Matlab® editor, then you can make copy and paste (paste > special), keeping the Octave syntax highlighting.
If you don't want to install KDE dependencies for run Kate I found a solution that could work until Scite implementation in GNU/Linux (?) haven't got the command "Copy as RTF", take a look here
So let's go:
sudo apt-get install wine synapse
wine: Windows Emulator ;)
synapse: fast application launcher
download notepad++ installer version
go to Downloads, chmod +x executable file (permissions to execute, could do graphically with properties of file, in permissions)
install it! (with default values works)
now you can run it easily with synapse:
if is launched: Ctrl+Space (or Super (windows key)+Space) and type "notepad" (if no appear, press Arrow Down and search it!)
write a text in, for example:
for i=1:3
%comment!
end
and now select it, with right button of mouse "plugin commands > copy text with syntax highlighting"
paste it!
in LibreOffice Writer: be carefull, use Ctrl+Shift+V or Edit>Paste Especial>Formated Text [RTF]
in Abiword works with Ctrl+V