Answer the question
In order to leave comments, you need to log in
How to automatically move files from lists to a specified folder?
How to implement this idea It is necessary that the script looks into the folder (for example, root/server) and if a file from the specified list appears in the folder (for example, test.cs), it automatically moves the file to the specified directory (for example, root/server/test)
Answer the question
In order to leave comments, you need to log in
I don’t really remember the python, but if I’m not mistaken, then so
import os, shutil
#path_1 и path_2 - путь
if str(os.listdir(path_1)).find("test.cs"):
shutil.move(path_1 + "text.cs", path_2)
I won’t tell you on python, on node.js you can do this:
const fs = require('fs');
fs.readdir(folderName, function(err, files) {
if (err) {
// обработка ошибки
} else {
if (!files.length) {
// каталог пустой
} else {
// каталог содержит файл
const oldPath = 'old/path/file.cs'
const newPath = 'new/path/file.cs'
fs.rename(oldPath, newPath, function (err) {
if (err) throw err
console.log('Файл перемещён')
})
}
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question