简体   繁体   中英

How do I run a batch script with a shortcut in Atom?

I am trying to configure Atom so that every time I press a certain keyboard shortcut (doesn't matter what specifically) it will pass a path of the file I have currently opened in Atom as an argument and run a batch file with that argument. Basically, it should copy the file I have opened from the working directory (the directory that Atom is opened in) to a directory specified in the batch script. Something like this exists in Sublime Text and there the batch script looks like this:

@echo off
:: Renaming arguments
set file_name=%1%
set file_path=%2%

:: Change this accordingly to your After Effects version
set version=CC 2017

:: Adobe After Effects folder location
set base_path=C:\Program Files\Adobe
set ae_folder_path=%base_path%\Adobe After Effects %version%
set ae_scripts_folder_path=%ae_folder_path%\Support Files\Scripts


cd "%file_path%"

:: Copying script to Scripts folder
copy "%file_name%" "%ae_scripts_folder_path%\%file_name%"

cd "%ae_folder_path%\Support Files"

:: Printing happy feedback in the console
echo "Successfully compiled %file_name% to 
%ae_scripts_folder_path%\%file_name%";

while the sublime_build itself looks like this:

{
  "cmd": [
  "sh '${packages}/AfterEffects/build.sh' '$file_name' && osascript 
  '${packages}/AfterEffects/run.scpt' '$file_name'"
  ],
  "shell": true,
  "windows": 
  {
    "cmd": ["${packages}/AfterEffects/build.bat", "$file_name", "$file_path"]
  }
}

It seems easy, but I have no idea how to pass a current file name and file path to a batch script and run it from Atom.

The first priority is to fix your batch file.

@Echo Off
Rem Renaming arguments
Set "file_name=%1"
Set "file_path=%2"

Rem Change this accordingly to your After Effects version
Set "version=CC 2017"

Rem Adobe After Effects folder location
Set "base_path=C:\Program Files\Adobe"
Set "ae_folder_path=%base_path%\Adobe After Effects %version%"
Set "ae_scripts_folder_path=%ae_folder_path%\Support Files\Scripts"

CD /D "%file_path%"

Rem Copying script to Scripts folder
Copy "%file_name%" "%ae_scripts_folder_path%\%file_name%"

CD /D "%ae_folder_path%\Support Files"

Rem Printing happy feedback in the console
Echo "Successfully compiled %file_name% to %ae_scripts_folder_path%\%file_name%";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM