我需要通过交换一些文本来重命名文件。例如:
eMail - 2015-11-28 1926.eml
second mail - 2016-07-26 1245.eml
third mL 2016-11-26 1410.eml
4-mail 2017-05-21 0105.eml
...
我想要他们
2015-11-28 1926 eMail - .eml
2016-07-26 1245 second mail - .eml
2016-11-26 1410 third mL.eml
2017-05-21 0105 4-mail.eml
...在这里可以找到的一种方式的一部分:
我尝试过
ls *.pdf | awk -F"[_.]" '{print "mv "$0" "$2"_"$1"."$3}' | sh
来自>
swap filename example
正在运行goog,但不适用于.eml
文件。
second swap filename example looks good too
但是我解决这个问题有点愚蠢
答案 0 :(得分:0)
如果public Rigidbody rb;
public Transform PlayerPosition;
// a flag to make sure there is only one animation at a time
private bool isMoving;
// a flag for altering between left and right movement
private bool isMovingRight;
// Update is called once per frame
void Update()
{
// only allow clicks while not moving already
if (!isMoving && Input.GetMouseButtonDown(0))
{
// stop further input until not moving anymore
isMoving = true;
// add the force
// (you might btw want to skip that Time.deltaTime here it makes no sense)
rb.AddForce(isMovingRight ? 20000 : -20000 * Time.deltaTime, 0, 0);
// alter the direction for the next call
isMovingRight = !isMovingRight;
// if you rather want to be able to interrupt the current animation by clicking again
// remove the isMoving flag and instead use this
//StopCoroutine(WaitForMoveStops());
// Start the routine
StartCoroutine(WaitForMoveStops());
}
}
private IEnumerator WaitForMoveStops()
{
// Inside a Coroutine while is okey now
// as long as you yield somwhere
// check if velocity is below threshold
while (!Mathf.Approximately(rb.velocity.magnitude, 0)
{
// yield in simple words means "leave" this method here, render the frame
// and than continue from here in the next frame
yield return null;
}
// I would now hard reset the velocity just to be sure
rb.velocity = Vector3.zero;
Debug.Log(PlayerPosition.position.x);
// whatever you want to do now
// reset the flag to allow input again
isMoving = false;
}
可用(regex
版本> = 3.2),请尝试以下操作:
bash
for f in *.eml; do
if [[ $f =~ ^(.+)\ +([0-9]{4}-[0-9]{2}-[0-9]{2}\ +[0-9]+)\.eml$ ]]; then
newname="${BASH_REMATCH[2]} ${BASH_REMATCH[1]}.eml"
mv -- "$f" "$newname"
fi
done
到捕获的组中。${BASH_REMATCH[@]}
分配给交换的文件名。