Automating the process of importing project into eclipse workspace using command line interface not working as expected - eclipse

I have command line argument for importing existing project into eclipse work space. But as soon as I try to execute it using windows batch file eclipse opens and starts loading and closes immediately. Here is the code that I am trying to run.
ECHO on
PUSHD
SET ECLPSE=%cd%
SET WORKSPACE=%~dp0
POPD
SET PATH=%PATH%;%ECLPSE%\bin;
RD /s /q %ECLPSE%\configuration\org.eclipse.equinox.app > Nul
RD /s /q %ECLPSE%\configuration\org.eclipse.osgi > Nul
RD /s /q %ECLPSE%\configuration\org.eclipse.update > Nul
START /B %ECLPSE%\bin\tresos_gui.exe -Dmsg1085=false -data %WORKSPACE% %*
START /B %ECLPSE%\bin\tresos_gui.exe importProject -c C:\Jenkins\jobs
This is the syntax for importing a project into the workspace.
tresos_cmd.bat [<system_property>...] [-data <workspace>]
importProject [-c] <project path>...
Can someone please help me with this. I would really appreciate it. I have even combined last two statements in one line and tried executing it but it is of no use. My main aim is to automate the process of importing project into eclipse workspace so that software can be built using jenkins.

All folder paths containing %ECLPSE% or %WORKSPACE% should be enclosed in double quotes in case of %cd% and/or %~dp0 expand to a folder path with a space character or one of the characters &()[]{}^=;!'+,`~.
I did not really understand what is the goal of the batch file and what tresos_gui.exe is for.
However, here is an improved and commented batch file.
#echo off
setlocal EnableExtensions
rem Path of current directory hold in environment variable CD usually does
rem not end with a backslash (directory separator on Windows). But if the
rem current directory is the root directory of a drive, the directory path
rem ends with a backslash. Assign current directory path to environment
rem variable ECLPSE (strange name) always without a trailing backslash.
if not "%CD:~-1%" == "\" ( set "ECLPSE=%CD%" ) else ( set "ECLPSE=%CD:~0,-1%" )
rem Path of batch file always ends with a backslash, but should be assigned
rem to environment variable WORKSPACE always without a trailing backslash.
set "WORKSPACE=%~dp0"
set "WORKSPACE=%WORKSPACE:~0,-1%"
rem The environment variable PATH can end with a folder path or with a
rem semicolon after last folder path. The subdirectory BIN in current
rem directory should be appended with an additional semicolon only if
rem environment variable PATH does not already end with a semicolon.
if "%PATH:~-1%" == ";" ( set "PATH=%PATH%%ECLPSE%\bin" ) else ( set "PATH=%PATH%;%ECLPSE%\bin" )
rem Command RD does not print any message on success. It prints only an error
rem message to handle STDERR if the directory tree could not be removed.
rd /Q /S "%ECLPSE%\configuration\org.eclipse.equinox.app" 2>nul
rd /Q /S "%ECLPSE%\configuration\org.eclipse.osgi" 2>nul
rd /Q /S "%ECLPSE%\configuration\org.eclipse.update" 2>nul
rem Command START interprets first double quoted string as title for the
rem command process window. Therefore specify as first parameter just ""
rem which is an empty title string.
rem The start of tresos_gui.exe is done for some unknown reason in a separate
rem process in background. Hold execution of batch file until this separate
rem process terminated itself before running tresos_gui.exe a second time
rem to import the project and best wait again until this process terminated.
start "" /WAIT /B "%ECLPSE%\bin\tresos_gui.exe" -Dmsg1085=false -data "%WORKSPACE%" %*
start "" /WAIT /B "%ECLPSE%\bin\tresos_gui.exe" importProject -c C:\Jenkins\jobs
endlocal
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
call /? ... explains %*
cmd /? ... explains with last paragraph on last help page when double quotes are required.
echo /?
endlocal /?
if /?
rd /?
rem /?
setlocal /?
start /?
And read also the Microsoft TechNet article Using command redirection operators for an explanation of 2>nul.

Related

Assist with batch file that searches and xcopy hidden file to specific dir

It's annoying to manually always search in the CMD and xcopy the hidden file, can someone whos good in scipting help me out?
I use these 2 commands:
Firstly i open CMD in the FOLDER2 and entering this command to find the hidden file in the hidden random sub dir:
dir /s /b | find "robotknow"
(robotknow is not the fullname of the file, only part of it.)
And then when it find the hidden file within the random made subdir i copy the whole path including the whole filename with the ending.
Xcopy /h *The whole path including the filename and ending* C:\hello
My folders:
$sourceDir = 'C:\Users\USER\AppData\Local\Packages\FOLDER1\FOLDER2'
$targetDir = 'C:\hello'
So i wish to create a batch that could search that string "robotknow" and copy the fullname of the file to my tagetdir.
Is it possible?
Im trying to learn commands but batching is harder, if i was unclear on anything please ask me thank you!
Edit:
I found few commands that could be useful but I dont know how to use them so that it works.
$searchStrings = For it to search after the string above i mentioned: "robotknow"
And
Copy-Item $_.FullName $targetpath
An example would be:
The filename has this in it's name "robotknow" and i want to copy it.
Copy the file im searching after to copy thats within the sub folder of the FOLDER2 which is an hidden random folder that i cannot se:
%LocalAppData%\Packages\FOLDER1\FOLDER2\THE-hidden-RANDOM-made-sub-DIR.
Copy it to it's final directory c:\hello
The final directory, simply just: c:\hello.
By hidden i mean that i cannot see in file explorer, windows GUI and neither if i put this simple command in CMD dir to show the hidden random folder where the file is located in, they are not showing.
The file only appears in CMD if i enter this command dir /s /b | find "robotknow" when im in the FOLDER2.
Only after that i can se the hidden random made dir/folder and the full hidden path to it (the file).
I suggest following batch file code for this task:
#echo off
setlocal EnableExtensions DisableDelayedExpansion
set "SourceFolder=%LocalAppData%\Packages\FOLDER1\FOLDER2"
set "TargetFolder=C:\hello"
for /F "delims=" %%I in ('dir "%SourceFolder%\*robotknow*" /A-D /B /S 2^>nul') do %SystemRoot%\System32\xcopy.exe "%%~dpI*" "%TargetFolder%\" /C /E /H /K /Q /R /Y >nul
endlocal
The command FOR with option /F starts a separate command process with cmd.exe /C (more precisely %ComSpec% /C) in background to run the command line:
dir "C:\Users\{username}\AppData\Local\Packages\FOLDER1\FOLDER2\*robotknow*" /A-D /B /S 2>nul
DIR outputs to handle STDOUT of background command process
just the names of all files matching the wildcard pattern *robotknow* because of option /A-D (attribute not directory)
even on file having hidden attribute set because of using option /A and not excluding attribute hidden
in bare format because of option /B
with full qualified path because of option /S
found in specified directory or any subdirectory also because of option /S.
It is possible that DIR does not find any file system entry matching these criteria in which case it outputs an error message to handle STDERR. This error message is suppressed by redirecting it to device NUL.
Read the Microsoft article about Using Command Redirection Operators for an explanation of 2>nul. The redirection operator > must be escaped with caret character ^ on FOR command line to be interpreted as literal character when Windows command interpreter processes this command line before executing command FOR which executes the embedded dir command line with using a separate command process started in background.
FOR with option /F captures all lines output to handle STDOUT of started command process and processes them line by line after started cmd.exe terminated itself.
FOR ignores empty lines which do not occur here. FOR ignores by default also all lines starting with a semicolon because of eol=; is the default for end of line character option. But a full qualified file name consisting of full file path, file name and file extension cannot start with ; and so default end of line option can be kept in this case. FOR splits up the lines by default into substrings with using normal space and horizontal tab character as string delimiters and assigns just first space/tab separated substring to specified loop variable. This line splitting behavior is not wanted here because of file path could contain a space character. For that reason option delims= is used to define an empty list of delimiters which disables the line splitting behavior.
So FOR assigns to specified and case-sensitive interpreted loop variable I the full qualified file name found and output by DIR and runs the command XCOPY.
XCOPY is executed with source being the full qualified path of found file referenced with %%~dpI always ending with a backslash concatenated with wildcard * and destination directory being specified target folder C:\hello.
The appended backslash at end of destination directory path makes it 100% clear for XCOPY that the destination is a directory and not a file which prevents the prompt if destination means a directory or a file. \ at end makes also usage of option /I unnecessary and XCOPY creates the entire destination directory structure if necessary.
The other XCOPY options are for really copying all files including files with hidden attribute set in directory containing the file matching the wildcard pattern *robotknow* with all subdirectories including empty subdirectories to destination directory with keeping attributes including read-only attribute.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
dir /?
echo /?
endlocal /?
set /?
setlocal /?
xcopy /?
See also the list of predefined Windows Environment Variables.

Loop through each line of text file and run command against each

I am trying to adjust some code which is shown below and hitting walls.
The commandline appears as:
cmd.exe /U /C "C:\Program Files\StorageCraft\ShadowProtect\VerifyImages.cmd <PathOfDirectoryWhichContainsImageFiles> <PathToOutputLogFile>
The code basically runs an image verify command against all md5 files in a directory. The problem is that some directories have >200 md5 files and I only want to verify the files created in the last 24 hrs.
I have been able to create a list of the files created in the last 24hrs and output to a text file using a powershell command.
Is it possible to adjust the script below so that it reads the text file line by line and runs the VERIFY_SUB against each? I have tried using the FOR /F command with little luck to this point.
Thanks in advance.
REM *** START OF MAIN ROUTINE ***
SETLOCAL
PUSHD
CD /D %~dp0
REM Strip the outer quotes off of the directory parameter
SET PARAM_DIR=%1
SET PARAM_DIR=###%PARAM_DIR%###
SET PARAM_DIR=%PARAM_DIR:"###=%
SET PARAM_DIR=%PARAM_DIR:###"=%
SET PARAM_DIR=%PARAM_DIR:###=%
REM Strip the outer quotes off of the output log file parameter
SET PARAM_OUTPUT_FILE=%2
SET PARAM_OUTPUT_FILE=###%PARAM_OUTPUT_FILE%###
SET PARAM_OUTPUT_FILE=%PARAM_OUTPUT_FILE:"###=%
SET PARAM_OUTPUT_FILE=%PARAM_OUTPUT_FILE:###"=%
SET PARAM_OUTPUT_FILE=%PARAM_OUTPUT_FILE:###=%
FOR %%A IN ("%PARAM_DIR%\*.md5") DO (call :VERIFY_SUB "%%A" "%PARAM_OUTPUT_FILE%")
POPD
ENDLOCAL
GOTO :EOF
REM *** END OF MAIN ROUTINE ***
:VERIFY_SUB
#ECHO VERIFYING MD5 FILE %1
#ECHO VERIFYING MD5 FILE %1 >> %2
image.exe v %1 >> %2
#ECHO. >> %2
#ECHO. >> %2
#ECHO. >> %2
GOTO :EOF

Is it possible to convert the epsilon or UltraEdit macro to exe?

If anyone know about how to convert the epsilon and UltraEdit macros to exe.
Could you please?
An UltraEdit macro can't be converted into an executable. The UltraEdit macro commands can be executed only by UltraEdit.
But it is possible to run an UltraEdit macro from within a batch file using UltraEdit to automate file reformatting tasks using an UE macro.
Here is a commented example for such a batch file:
#echo off
rem Get name of UltraEdit executable with full path from Windows registry.
set "UltraEditEXE="
call :GetFileNameUE "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\uedit32.exe"
if not "%UltraEditEXE%" == "" goto RunMacro
call :GetFileNameUE "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\uedit64.exe"
if not "%UltraEditEXE%" == "" goto RunMacro
call :GetFileNameUE "HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\uedit32.exe"
if not "%UltraEditEXE%" == "" goto RunMacro
call :GetFileNameUE "HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\uedit64.exe"
if not "%UltraEditEXE%" == "" goto RunMacro
echo UltraEdit is not installed most likely as no uedit*.exe found.
echo.
pause
goto :EOF
rem Run UltraEdit using Windows command start to run UE minimized with forcing
rem always an new instance of UltraEdit, opening a file and processing this
rem file with an UltraEdit macro. This instance of UltraEdit is automatically
rem exited after macro executed once on the opened file. The macro must save
rem the file before exiting. While UltraEdit is running the batch procssing
rem is continued with deleting the environment variable and then exiting
rem batch processing. See in help of UltraEdit the page with title "Command
rem Line Parameters" for details on the used UE command line parameters.
:RunMacro
start "Run UE macro" /min "%UltraEditEXE%" /fni "Path\Name of file to modify.txt" /M,E,1="Macro file with full path/Macro Name"
set "UltraEditEXE="
goto :EOF
rem This is a subroutine called up to 4 times to determine name of UltraEdit
rem executable with full path from Windows registry if UltraEdit is installed
rem at all. It assigns file name of UltraEdit with full path and with file
rem extension to environment variable UltraEditEXE on success finding the
rem registry value in registry key passed as parameter to this subroutine.
:GetFileNameUE
for /F "skip=2 tokens=3*" %%A in ('%SystemRoot%\System32\reg.exe QUERY %1 /ve 2^>nul') do (
if "%%A" == "REG_SZ" set "UltraEditEXE=%%B" & goto :EOF
)
goto :EOF
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
call /?
echo /?
for /?
goto /?
if /?
pause /?
reg query /?
rem /?
set /?
start /?

rename multiple files in order with command prompt

I have some files with different names.
Leviathan.txt,Dragon.txt and so on
I wanted to turn it into a digit begins
1.txt,2.txt,3.txt,4.txt and so on
how to perform like other language by using For and function that can pass amount files in folder?
my code so far i know is dir and ren. and i stuck now.
ren *.txt 1.txt
Next code snippet could work for you (save with .bat extension); note that rename command is echoed merely for debugging purposes:
#echo off
SETLOCAL enableextensions enabledelayedexpansion
set /A "ii=0"
pushd "working_directory_here"
for /F "delims=" %%G in ('dir /B /ON "*.txt" 2^>NUL') do (
set /A "ii+=1"
echo ren "%%~G" "!ii!%%~nxG"
)
popd
If you insist on an one-liner (launch in proper working directory):
cmd /E:ON /V:ON /K (#echo off^&set /A "ii=0" ^>NUL^&for /F "delims=" %G in ('dir /B /ON "*.txt" 2^^^>NUL') do (set /A "ii+=1" ^>nul^&echo ren "%~G" "!ii!%~nxG"))^&exit
Resources (required reading):
(command reference) An A-Z Index of the Windows CMD command line
(additional particularities) Windows CMD Shell Command Line Syntax
(%~G etc. special page) Command Line arguments (Parameters)
(EnableDelayedExpansion) Setlocal EnableDelayedExpansion
(^>, %% etc.) Syntax : Escape Characters, Delimiters and Quotes
Assuming none of your existing files are already named something like n.txt, where n is a number, then simply CD to your folder, and run the following command from the command line:
for "tokens=1* delims=:" %A in ('dir /b *.txt^|findstr /n "^"') do #ren "%B" "%A.txt"
Double up the percents if you use the command within a batch script.
EDIT
I forgot about my JREN.BAT utility - a regular expression renaming utility. It is pure script (hybrid JScript/batch) that runs natively on any Windows machine from XP onward.
JREN has a built in ability to incorporate a number into each new file name, and as an added bonus, it can left pad the number with zeros so that a DIR command lists the files in numerical order. The default numeric width is 3 digits, so files would be like "001.txt", "002.txt', ... "010.txt", ... "100.txt", etc.
jren "^.*" "$n+'.txt'" /j /fm *.txt
The /NPAD option specifies the minimum numeric width, so NTAB 1 produces no padding, which is what the original question asked for.
jren "^.*" "$n+'.txt'" /j /fm *.txt /npad 1
Since JREN is a batch script itself, you must use CALL JREN if you put the command within another batch script.
Full documentation is available from the command prompt via jren /? | more. My console window is configured with a large buffer, so I can scroll back to see prior output, and I don't bother with piping the help to MORE.

eol unix to windows in command line .bat batch

I am trying to convert text file eol to windows format from unix on windows xp machine using command line (batch file). how do I do that? what is the command for that? thanks.
This simple script is fast and works great except it converts every TAB character into 8 spaces. The number of spaces can be modified with the MORE /T option, but there is no way to preserve the TAB characters. Pass the file name (optionally with path) as the one and only argument.
#echo off
more %1 >%1.new
move /y %1.new %1 >nul
All that is needed is to read and echo each line. The FOR /F command is perfect, except it ignores empty lines. Here I use FINDSTR to prefix each line with the line number, followed by a :, thus preserving empty lines. Then I use search and replace to remove the number prefix. I must toggle delayed expansion on and off within the loop to preserve any ! that may appear. This script preserves TABs, but is limited to ~8191 bytes per line. It is also relatively slow. It will become very slow with very large files.
#echo off
setlocal disableDelayedExpansion
>%1.new (
for /f "delims=" %%A in ('findstr /n "^" %1') do (
set "ln=%%A"
setlocal enableDelayedExpansion
echo(!ln:*:=!
endlocal
)
)
move /y %1.new %1 >nul
Finally, here is a hybrid batch/JScript solution that is very fast, and does not have any limitations that I am aware of.
#if (#X)==(#Y) #end /* Harmless hybrid line that begins a JScript comment
::************ Batch portion ***********
#echo off
<%1 cscript //E:JScript //nologo "%~f0" >%1.new
move /y %1.new %1 >nul
exit /b
************* JScript portion **********/
while (!WScript.StdIn.AtEndOfStream) {
WScript.Stdout.WriteLine(WScript.StdIn.ReadLine());
}