Jump to content

Convert your existing bash scripts & batch files to ducky script


Recommended Posts

I wrote a simple script for both windows and linux, txt2ducky that will turn this

@echo off
@echo Super cool awesome batch file

into this

STRING @echo off
STRING @echo Super cool awesome batch file
STRING ipconfig

Nothing earth shattering, but I find it useful anyway. I'm sure it's been done before, but I couldn't find any examples soooo... whatever, here it is.


Windows: txt2ducky.cmd
Linux/etc: txt2ducky.sh



txt2ducky inputfile [outputfile]


Roll Your Own

If you want to use the code in another (batch file) project, all you really need is

FOR /F "usebackq delims=" %%I IN ("%FILEIN%") DO (
    @echo STRING %%I >> "%FILEOUT%"
    @echo ENTER      >> "%FILEOUT%"

or in a bash script, go for...

while read -r line; do
    echo STRING $line >> $fileout
    echo ENTER        >> $fileout
done < $filein


Just RegEx It!

You can of course achieve the same thing was a simple RegEx find and replace...
Find: .*
Replace: STRING $0\nENTER


Wrapping Up

Hopefully someone else finds it useful.

More details available on the GitHub Repo.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...