D
D
Dmitry Gusikov2021-07-12 12:05:59
Automation
Dmitry Gusikov, 2021-07-12 12:05:59

How to auto-rename a google sheets (google sheets) cell when renaming a folder?

Is it currently possible to create a dependency in Google Sheets on folders? Those. if I rename a certain folder, the cell name or path in google sheets also changes. Maybe there are some interesting macros or something like that. At least directions for deepening if you tell me, I will be grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Damir Makhmudov, 2021-07-12
@Dicur3x

hello, yes it is only possible with a script. If you have no experience in programming, share the table I will help [email protected]
You need to enter the Google spreadsheet code editor. First you need to decide how new folders will get into the table. For example, a button or automatically - it doesn't matter. For example, you have a bunch of folders located in the water main directory. You can run through its composition and check with what is in the table.

let sp = SpreadsheetApp.getActiveSpreadsheet() - подключаемся к нашей таблице
let sheet = sp.getSheetByName() - имеем дело в листом котором данные

let cell = sheet.getRange(2,3) - обратились к ячейке по корординатам (способом много)
let id = cell.getValue() - взяли значение например id

let mainFolder = DriveApp.getFolderById() - также можно получить папку по id (id находится в url папки)
let folders = mainFolder .getFolders - так можно получить все папки внутри

while (folders.hasNext()) { так мы бегаем по всем папкам внутри и вытаскиваем имя
  let folder = folders.next();
  let name = getName();
}

If you need to automatically change something in the table when changing the folder name, for example, then you need to create a trigger - in the same place in the code editor. Create a trigger and connect it to a function that will search for dad by id and update the name in the table in the desired cell.
Briefly like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question