我有一个脚本,可以按文件名过滤文件,例如,如果文件名包含“(日本)”,它将被移动到“已删除”目录。
offline_access
...脚本从这里继续
这是可行的,但似乎缺少特定文件:
<?php
$gameList = trim(shell_exec("ls -1"));
$gameArray = explode("\n", $gameList);
shell_exec('mkdir -p Removed');
// Do this magic for every file
foreach ($gameArray as $thisGame)
{
if (!$thisGame) continue;
// Probably already been removed
if (!file_exists($thisGame)) continue;
$niceName = trim(preg_replace('%[\(|\[].*%', '', $thisGame));
// Non-Engish speaking countries e.g. (France) or (Japan)
if (preg_match('%\((Asia|Austria|Brazil|China|Denmark|Finland|France|Germany|Greece|Hungary|Israel|Italy|Japan|Japan, Asia|Korea|Netherlands|Norway|Poland|Portugal|Russia|Scandinavia|Spain|Sweden)\)%', $thisGame))
{
echo "{$thisGame} is a foreign language release. Moved to Removed folder.\n";
shell_exec("mv \"{$thisGame}\" Removed/");
continue;
}
和
...Iru! (Japan).zip
命名一对。我想这与他们有趣的角色有关。我不认为这是感叹号(!),因为带有它的其他文件已被正确过滤,所以它是句号吗? (。)在第二个文件中,我猜是美元符号($)。
有关如何解决此问题的任何建议?非常感谢!
答案 0 :(得分:0)
由于直接执行Shell命令,因此需要转义Shell元字符。将此放在最后import numpy as np
import pandas as pd
df = pd.DataFrame({'Name':
['a','b','c','d','e','f','g','h','j','k'],'Age':np.random.randint(3,26,10)})
df = df.sort_values('Age')
df['CumSum'] = df['Age'].cumsum()
df['Percent_CumSum'] = 100*df.CumSum/df.Age.sum()
df['Buckets'] = pd.cut(df.Percent_CumSum,bins=[0,20,40,60,80,100],\
labels=['p','s','m','l','xl'],right=True)
之前的位置:
shell_exec