简体   繁体   中英

Comparing last-modified date

I am trying to translate a linux bash script to windows. I have two questions:

  • How to strip the extension part of a filename?
  • How to compare the last-modified date of two files?

The original bash script is:

#!/bin/bash

file=$1
name=${file%.*}

if [ "$1.scala" -ot "$file" ]; then
    java -jar ./potigol/potigol.jar -d $file > $name.scala
fi
./scala-2.11.8/bin/scala -save -cp potigol/potigol.jar $name.scala 2> /dev/null

Thank you @squashman. I found the answer in the help of the CALL and FOR commands:

@echo off
SET scala_file=%~n1.scala
SET t1=%~t1
FOR %%A IN (%scala_file%) DO (SET t2=%%~tA)
IF "%t1%" GTR "%t2%" (
    java -jar potigol\potigol.jar -d %1 > %scala_file%
)
scala-2.11.8\bin\scala -save -cp potigol\potigol.jar %scala_file% 2> NUL

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